General mode |
Cursor movement |
h or left ARROW key |
The cursor moves one character to the left |
J or DOWN ARROW key |
Move the cursor down one character |
k or up ARROW key |
Move the cursor up one character |
l or right ARROW key |
The cursor moves one character to the right |
Ctrl+f |
Screen forward one page (common) |
Ctrl+b |
The screen turns back one page (common) |
Ctrl+d |
The screen turns half a page forward |
Ctrl+u |
The screen turns half a page forward |
+ |
Cursor moves to the next column of non-whitespace |
- |
Cursor moves to the previous column of non-whitespace |
n<space>
|
When you press the number and then press the SPACEBAR, the cursor moves the n characters of the line to the right. For example 20<space>, the cursor moves to the right by three characters |
0 |
(is the number 0) The first word to move to this line prompt (common) |
$ |
Move to the last word of this line prompt (common) |
H |
The cursor moves to the top row of the screen |
M |
The cursor moves to the line in the center of the screen |
L |
The cursor moves to the bottom line of the screen |
G |
The cursor moves to the last line of the screen |
NG |
Move to the nth row of this file. For example 20G, it will be moved to the first line of this file (mate : Set Nu) |
N<enter> |
Move the cursor down n rows (common) |
General mode |
Find and replace |
/word |
Find a string named word after the cursor (common) |
? word |
Look for a string named Word before the cursor |
: n1,n2s/word1/word2/g |
Find the word1 string between the N1 and n2 lines and replace the string with Word2(Common) |
: 1, $s/word1/word2/g |
Finds the word1 string between the first line and the last row and replaces the string with Word2(Common) |
: 1, $s/word1/word2/gc
|
Finds the word1 string between the first line and the last row, replaces the string with Word2, and displays a prompt for the user to confirm (conform)before replacing (common) |
General mode |
Delete, copy, and paste |
X,x |
x to remove one character backwards,x to delete one character forward (common) |
Nx |
Remove n characters backwards |
Dd |
Delete the entire line where the cursor is located (common) |
Ndd |
Delete the down N column of the column where the cursor is located, for example,20dd deletes the column (common) |
d1g |
Delete all data from the row to the first row of the cursor |
Dg |
Delete all data from the column that contains the cursor to the last row |
Yy |
Copy cursor Line (common) |
Nyy |
Copy the down N column of the column where the cursor is located, for example,20yy is the Copy column (common) |
y1g |
Copy all data from the column to the first column of the cursor |
YG |
Copy all data from the column of the cursor to the last column |
P,p |
p Paste the copied data in the next column of the cursor,p is pasted on the cursor column (common) |
J |
Combine data from the cursor column and the next column into one column |
U |
Redo previous action (common) |
Edit mode |
I,i |
Insert: Inserts the input text at the current cursor position, already exists |
A,a |
Add: Input is started by the next character where the current cursor is located, and the existing character is backward (common) |
O,o |
Insert a new line: Enter characters from the beginning of the next line in the row where the cursor is located (common) |
R,r |
Replace:R replaces the character that the cursor refers to, andR will always replace the text indicated by the cursor until ESC is pressed (common) |
Esc |
Exit edit mode, return to normal mode (common) |
Command-line mode |
|
: W |
Writing edited data to a hard disk file (common) |
: w! |
If the file property is read-only, force the file to be written |
: Q |
Exit VI(Common) |
: q! |
If you have modified the file, do not want to save, use ! do not save file for forced exit |
: Wq |
Exit after saving, if : wq!, exit after force save (Common) |
: W[filename] |
Save the edited data as another file (similar to saving a new document) |
: R[filename] |
In the edited data, read the data from the other file. The filename will be appended to the following line of the cursor |
: Set Nu |
Displays the line number, which, when set, displays the line number in front of each row |
: Set Nonu |
In contrast to ser nu , the line number is canceled |
N1,N2 W[filename] |
Save the contents of N1 to n2 as filename for this file |