Linux CentOS VI/VIM command
INSERT command:
A attaches text behind the cursor
A adds text at the end of the line
I insert text before the cursor
I. Start inserting text in this row
O Insert a new line under the cursor
O Insert a new line to the cursor
Positioning command in VI:
H. left-click to move one character to the left
J. Move down a line
K. Move a row up
L. Right-click the direction and move one character to the right.
$ Move to the end of the row
0. Move to the beginning of the line
H. Move to the top of the screen
M. Move to the center of the screen
L move to the bottom of the screen
[CTRL] [d] half a page [PageDown]
[CTRL] [f] to the next page
[CTRL] [u] up half page
[CTRL] [B] [PageUp]
: Set nu
: Set nonu cancel row number
Gg to the first line
G to the last line
NG to n
: N to row n
DELETE command:
X. Delete the character at which the cursor is located
Nx: Delete the last n characters at the cursor location
Dd: Delete the row where the cursor is located, and ndd deletes n rows.
DG. Delete the content from the row where the cursor is located to the end.
D. Delete the cursor from the position to the end of the row.
: Nl, n2d, delete rows in the specified range
Copy and cut commands:
Yy and Y copy the current row
Nyy and nY copy n rows below the current row
Dd: Cut the current row
Ndd cut n rows below the current row
P and P are pasted under or on the row where the current cursor is located.
Replacement and cancellation commands:
R, replace the character where the cursor is located
R. Replace the character from where the cursor is located and Press Esc.
U. Cancel the previous operation.
Search and replace commands
/String: Specifies the string to be searched forward. Case sensitivity is ignored during search: set ic
N. Search for the next occurrence location of a specified string
: % S/old/new/g, full text replacement of the specified string
: Nl, n2s/old/new/g, replace the specified string within a certain range
Save and exit: wq. You can also use ZZ to replace this command.