In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "linux vi editor commonly used commands", the explanation content in the article is simple and clear, easy to learn and understand, please follow the small series of ideas slowly in-depth, together to study and learn the "linux vi editor commonly used commands" bar!
There are three state modes in the vi editor
1. command mode
2. input mode
3. last row mode
Interconversion between three modes
Start and exit vi editor
Direct access to editing environment
$ vi
Enter the editing environment and open the (New) file
$ vi myfile
Exit vi editing environment
Enter the last line command to discard changes to the file and exit the editor
:q!
File Save vs. Save As
save the file
save changes to files already open in vi editor
:w
save as a file
Save contents of vi editor as specified file name
:w myfile
Multiple ways to exit vi editor
Unmodified Exit
Exit vi editor without making changes to files open in vi editor or saving changes
:q
save and exit
Save files in vi editor and exit vi editor
:wq
exit without saving
Discard changes to file contents and exit vi editor
:q!
Cursor movement and page turning operations
Operation type Cursor operation key function
Cursor movement h Move cursor to the left
l Move cursor to right
k Move cursor up
j Move cursor down
Ctrl + f: Turn the page forward
Ctrl + b Flips back the entire page
Ctrl + u Scroll forward half a page
Ctrl + d Scroll back half a page
Quick jump in line
Function of operation keys
^Jump the cursor quickly to the first character of the line
$Jump the cursor quickly to the end of the line character
w Quickly jump the cursor to the first letter of the next word at the current cursor position
b Quickly jump the cursor to the first letter of the word before the current cursor position
e Quickly jump the cursor to the last letter of the word after the current cursor position
Quick jump between file lines
command function
:set nu Show line numbers in the editor
:set nonu Cancel line numbers in the editor
1G Go to the first line of the file
G Go to the end of the file
#G Jump to line #in file
Enter input mode
command function
i enters the insertion state at the current cursor
a Enter insert state after current cursor
A Move the cursor to the end of the current line and enter the insertion state
o Insert a new line below the current line. Move the cursor to the beginning of the new line to enter the insert state.
O Insert a new line above the current line. Move the cursor to the beginning of the new line to enter the insert state.
cw deletes the character at the end of the word where the current cursor is located, and enters the insertion state
c$Delete the character from the current cursor to the end of the line and enter the insertion state
The c^command deletes the characters from before the current cursor (excluding the characters on the cursor) to the beginning of the line and enters the insertion state.
Edit key operation of input mode
key function
Arrow keys for up and down left and right direction of cursor movement
Home Quickly position the cursor to the beginning of the line
End Quickly position the cursor to the end of the line
PageUp Page up of text
PageDown Page Down of text
Backspace Delete the character to the left of the cursor
Del Delete character at cursor position
delete operation
command function
x Delete single character at cursor
dd Delete cursor row
dw Delete all characters from the current character to the end of the word (including spaces)
de Delete all characters from the current character to the end of the word (excluding spaces at the end of the word)
d$Delete all characters from the current character to the end of the line
d^Delete all characters from the current character to the beginning of the line
J Delete the newline at the end of the line where the cursor is located, which is equivalent to merging the contents of the current line and the next line.
undo operation
command function
u Cancel the last operation and restore the operation result
You can use the u command several times to recover from a multistep operation that has been performed
U Cancels all operations on the current row
Ctrl + r Restores actions undone with the u command
Copy and paste operations
command function
yy copies the entire contents of the current line to vi buffer
yw copies the contents of the current cursor to the last character of the word into the vi buffer
y$copies the contents of the current cursor to the end of the line into the vi buffer
y^Copy the contents of the current cursor to the beginning of the line to the vi buffer
p Read the contents of the vi buffer and paste it to the current cursor position (without overwriting the existing contents of the file)
string lookup operation
command function
/word Find the string "word" in the file from top to bottom
? word Find the string "word" in a file from the bottom up
n locates the next matching searched string
N locates a matching searched string on
string substitution operation
command function
:s/old/new Replace the first string of characters found in the current row "old" with "new"
:s/old/new/g Replace all strings found in the current row with "new"
:#,#s/old/new/g Replace all strings "old" with "new" within line number "#,#"
:%s/old/new/g Replace all strings "old" with "new" throughout the file
:s/old/new/c Add the c command to the end of the substitution command to prompt the user for confirmation of each substitution action
vi editor online help
Install packages to use vi online help
vim-common-6.3.035-3.i386.rpm
vim-enhanced-6.3.035-3.i386.rpm
Package on RHEL5 2nd installation CD
Two ways to use vi online help
Press "F1" key in vi editor
Enter the help last line command
:help
Thank you for reading, the above is the "linux vi editor commonly used commands" content, after the study of this article, I believe we have a deeper understanding of the linux vi editor commonly used commands this issue, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.