Position command
Command function
H Move one character to the left
J Move down one line
K Move up one line
L Move one character to the right
$ move to end of line
0 Move to the beginning of the line
H move to upper screen
M moves to the center of the screen
L Move to the bottom of the screen
Quick positioning
Command function
: Set nu Displays line number
: Set Nonu Cancel line number
GG move to first line
G move to last line
NG to Nth row
: N to nth row
Delete command
X Delete the character of the cursor
NX Delete n characters
DD Deletes the row where the cursor is located, NDD deletes n rows
DG Deletes all rows from the current line to the end of the file , including the current row
D Delete the contents of the cursor at the end of the line
: n1,n2d Delete n1~n2 line
Copy command
yy copy when moving forward
Nyy,ny copy n rows
DD cuts the current line, NDD cuts the current row and N rows
P pasted below the current line
p[uppercase] pasted on the current line
Replace or Cancel command
R replaces the character at which the cursor is located
R replaces the character at the cursor position until ESC ends
You cancel the previous operation, first you have not saved, the document is still in memory, has not synced to the hard disk.
Replace or Search command
/string Searches backward for the specified string, ignoring case when searching: Set IC, Cancel: Set Noic
N from head to back
n turn from back to forward
:%s/old/new/g Full text replaces the specified string, old is the keyword that needs to be replaced.
: n1,n2s/old/new/g replaces specified string within a certain range
:%s/old/new/C replaces the specified string with the full text, but asks
Save and exit
ZZ: shortcut keys for Wq
: w new_filename Save as specified file
: wq! Forcibly save changes and exit [root/file owner]
: q! do not save exit
Continuous line Comment
: n1,n2/^/#/g#在n1到n2行的行首加 #
: n1,n2/#//g#去掉n1到n2行行首的 # Remove
This article from "All Technical Blog" blog, reproduced please contact the author!
Vim's Operation