First, the common key description
1. General mode
Keys |
Description |
0 |
Move to the front of the line |
$ |
Move to the last face of the line |
G |
Move to the last line |
NG |
Move to Nth row |
X |
Remove one character backwards |
Dd |
Delete the row |
Ndd |
Delete N rows |
Yy |
Copy the row |
Nyy |
Copy n rows |
P |
Paste a line on the cursor |
U |
Revoke |
. |
Repeat previous action |
2. Command-line mode
Keys |
Description |
: W |
Save |
: Q |
Leave |
: Wq |
Leave after saving |
Zz |
Equivalent to: Wq |
: W[filename] |
Save in filename |
: Set Nu |
Show line Numbers |
: Set Nonu |
Cancel line number |
/word |
Find word down |
: 1, $s/word1/word2/g |
Replace the word1 with the Word2 |
Ii. Other Notes
VI is divided into 3 modes: General mode, edit mode, command line mode
You cannot switch between edit mode and command line mode.
In VI, the [TAB] key results are not the same as the results obtained by the space character.
Vim also has 3 important functions: Block selection, multi-file editing, multi-window function
Use of Vim