General Mode : Enter the "vim file name" in the Linux terminal to enter the general mode , but cannot enter the text.
edit Mode : Press I in general mode will enter the editing mode , you can write the program, press ESC to return to the general mode .
command mode : Press in normal mode : Will enter command mode , there will be a colon in the lower left corner, at this point, you can type the command and execute.
Command mode :
| I |
Enter in front of the cursor |
I |
Enter at the beginning of the line |
| A |
Enter after the cursor |
A |
Enter at the end of a row |
| O |
Enter at the beginning of the next line in the row where the cursor is |
O |
Enters the line at the beginning of the row where the cursor is located |
| cw |
Modify a Word |
Dw |
Delete a word |
| Dd |
Delete a row |
U |
Undo Last Action |
| Ctrl+r |
Restart last action |
Gg |
Cursor quickly back to the bottom of the file |
| Gg |
Quick cursor back to file header |
4dd |
Delete 4 lines at the beginning of the line where the cursor is located |
| P |
Paste at the next line of the cursor |
Yy |
Copy a row |
| d$ |
Delete the character after the cursor is the end of the line |
|
|
Last-line mode :
| Q |
Exit |
Q! |
Force exit |
| W |
Save |
Wq |
Save and exit |
| wq! |
Force Save and exit |
Set Nonu |
Do not display the number of rows |
| Set Autoindent |
Auto Align |
Set Noautoindent |
To cancel automatic alignment |
| 1,5s/mail/gmail/g |
Global substitution (1-5 rows) |
1, $s/mail/gmail/g |
Global substitution |
Vim three modes and commands for Linux