From the Unix Beginner's Tutorial (fourth edition).
Command mode switch to text input mode:
Key |
Function |
I |
Enter text to the left of the cursor |
I |
Enter text at the beginning of the current line |
A |
Enter text to the right of the cursor |
A |
Enter text at the end of the line at the current line |
O |
Adds a blank line to the next line in the current row, with the cursor at the beginning of the new line |
O |
Adds a blank line to the top row of the current row, with the cursor at the beginning of the new line |
Regardless of which shortcut key is used to enter this mode, in insert mode, it is inserted before the cursor.
Text modifier keys, only available in command mode
Key |
Function |
X |
Deletes the specified character at the cursor position |
Dd |
Delete the line where the cursor is located |
U |
Undo Recent Changes |
|
|
R |
Replaces one character at the cursor position |
R |
Replaces characters starting at the cursor position, while changing vim to text input mode |
. |
Repeat the last modification |
The cursor moves the key, and the command mode controls the cursor movement.
Key |
Function |
h or [←] |
Move the cursor to the left one |
J or [↓] |
Move the cursor down one line |
K or [↑] |
Move the cursor up one line |
I or [→] |
Move the cursor to the right one |
NG |
Transfer to Nth row |
G |
Skip to Tail line |
Dg |
Delete all |
The Exit command, in addition to the ZZ command, starts with ":" and ends the command line with [Enter].
Key |
Function |
Wq |
Save the file, exit the editor |
W |
Save the file, but do not exit the editor |
Q |
Exit editor |
Q! |
Do not save the file, exit the editor |
Zz |
Save the file, exit the editor |
Search command
Key |
Function |
/ |
Search forward to the specified string, and then press N to search for the next |
? |
Search backwards for the specified string, search to press N to find the next |
Vim basic commands (reproduced from the network)