Vi editor's text description mode: Command mode, edit mode, and last line mode. Switch Mode: Command mode → I → edit mode, edit mode → Esc → command mode, command mode →: → last line mode. Function: Command Mode: controls the movement of the cursor, deletes characters, and copies paragraphs.
Insert Mode: adds and modifies text.
Last Line Mode: saves the file, leaves vi, and other settings.
Command mode command instructions
H. move the cursor to the left
L move the cursor to the right
J. move the cursor down a grid
K move the cursor up a grid
0: 0. move the cursor to the beginning of the row.
$ Move the cursor to the end of the row
H move the cursor to the top of the screen
M move the cursor to the center of the screen
L move the cursor to the bottom of the screen
Gg moves the cursor to the first line of the article
G move the cursor to the end of the article
W or W move the cursor to the next word
X Delete the character at the cursor
X Delete the character before the cursor
Dd deletes the row where the cursor is located.
* Dd deletes the row from the row where the cursor is located. * The row is a number.
D. Delete the cursor from the position to the end of the row.
R replaces a character at the cursor
R is replaced from the cursor and ended by Esc.
U cancels the operation in the previous step
U cancels all current operations
Yy copy the row where the cursor is located
P: place the copied content to the downlink of the row where the cursor is located.
Edit mode command instructions
A insert text behind the cursor
A inserts text behind the row where the cursor is located
I insert text before the cursor
I insert text in front of the row where the cursor is located
O Insert a new line (lowercase letter o) under the row where the cursor is located)
O Insert a new line (uppercase letter O) on the row where the cursor is located)
Last-line command description
E. Create a new file.
N load new files
W save the file
! Forcible operation
W! Forcibly save files
Q exit
Q! Force exit
Wq save and exit
Wq! Forcibly save and exit
Set nu display row number
Set nonu does not display row numbers
/*/Search, * any string
? Basically, the above operations are enough.