Vim Editor basic commands (top)
Three modes:
Edit mode, input mode, last line mode
Default to edit mode
Mode conversion:
Edit mode--Input mode:
I:insert, enter at the cursor position
A:append, enter at the rear of the cursor
O: Opens a new line below the cursor location;
I: Enter at the beginning of the line where the cursor is located
A: Enter at the end of the line where the cursor is located
O: Opens a new line entry above the cursor location
Input mode--edit mode: ESC
Edit mode--and last-line mode::
Last-line mode--edit mode: ESC
To close a file:
ZZ: Edit mode Save and exit
Last-line mode close file
: Q exit
: q! Forced exit
: Wq Save and exit
: X Save and exit
: W/path/to/somefile saved to/path/to/somefile file
Cursor Jump:
Jump between characters:
H: Left L: Right J: down K: Upper
#COMMAND: Jump # characters;
Jump between words:
W: The first word of the next word;
E: The ending of the current or next word;
B: The first word of the current or previous word;
#COMMAND: Jump # words
Beginning line End Jump:
^: Jump to first non-whitespace character at beginning of line
0: Jump to the beginning of the line
$: Jump to end of line
Inline Jump:
#G: Jump to # line
1g,gg: Jump to the first line
G: Jump to the last line
Jump between sentences:
(
)
Jump between Segments:
{
}
Flip Screen:
CTRL+F: Flip a screen to the end of a file
Ctrl+b: Turn one screen at the top of the file
Ctrl+d: Half-screen to the end of the file
Ctrl+u: First half screen to file
Enter: Turn Backward by line
Vim's edit command:
Character editing:
X: Delete the character at the cursor;
#x: Delete the # characters at the beginning of the cursor;
XP: Swap the position of the character at the cursor and the character behind it
Replace command (replace)
R: replaces the character at which the cursor is located;
Rchar
Delete command:
D: Delete command, can be combined with the cursor jump character, to achieve range deletion
d$;
d^:
Dw:
De
Db:
#COMMAND
DD: Delete Row
#dd: Delete the line after the start of the line where the cursor is at
Paste command:
P: The contents of the buffer are pasted below the line where the current cursor is, if the entire row is the same;
P: The contents of the buffer are pasted at the top of the line where the current cursor is, if the whole row is the same; otherwise, paste to the front of the current cursor;
Copy command: (yank,y)
Y: Copy, working behavior similar to D
y$
y^
Y0
Ye
yw
Yb
#COMMAND
YY: Copy a whole line
#yy: Copy # lines
Change command (CHANGE,C):
Implementation of the delete operation, and edit mode--Output mode
C $
c^
C0
Cb
Ce
cw
#COMMAND
CC: Delete the line where the cursor is located and convert to output mode
#cc:
Other editing operations:
Visualization mode:
V: Selected by character
V: Selected by row
Combine edit command: d,c,y
Undo Action:
U:undo revoke the previous operation;
#u: Undo Previous # Operations
To revoke a previous revocation:
Ctrl+r
Repeat the previous edit operation:
.
Vim comes with a practice tutorial: Vimtutor
Vim Editor (top)