Vim operation
1. Insert command
Command |
Operation |
I |
Insert before cursor position |
I |
line where the cursor is located, beginning with insertion |
A |
Insert after cursor position |
A |
line with cursor, end of line insert |
|
The line where the cursor is located, and another line is inserted |
O |
Line with cursor, insert up another line |
S |
Delete character insertion |
S |
Delete entire row insert |
. |
Repeat the previous command |
2. Positioning commands
Command |
Operation |
0 Number 0 |
Header |
$ |
End of Line |
Gg |
Beginning of first line |
G |
Beginning of last line |
NG (n for number) |
Position to Nth row, beginning of line |
: N + Enter |
Position to Nth row, beginning of line |
{ |
Duan Song |
} |
Duan Mei |
% |
Move to the matching {}. (). [] at |
H |
Move the cursor to the top of the screen |
M |
Move the cursor to the middle of the screen |
L |
Move the cursor to the bottom of the screen |
* |
Reads the current character and moves to the next occurrence |
# |
Reads the current character and moves to where it was last seen |
3. Delete command
Command |
Operation |
X |
Delete Cursor position character |
NX (n for number) |
Delete n characters after cursor position |
Dd |
Delete the row of the cursor, the entire row |
Ndd |
Delete the n rows after the cursor line, including the cursor row |
Dg |
Delete the line of the cursor to the end of the file |
D |
Delete cursor position to end of line |
d$ |
Delete cursor position to end of line |
Dw |
Delete a word after the cursor position (the word is separated by a space) |
: N1,n2 D (n1,n2 as line number) |
Delete rows of the specified row range |
4. Copy and Cut commands
Command |
Operation |
Yy |
Copy cursor row, entire row |
Nyy (n is number) |
Copy the current row and the following n rows |
Dd |
Cut when moving forward |
Ndd |
Cuts the current row and the following n rows |
P (uppercase) |
Paste to the line where the cursor is located, the previous row |
P |
Paste to the line where the cursor is located, the next line |
Xp |
Swap two characters |
Ddp |
Swap two lines |
5. Search and search replacement commands
Command |
Role |
/string |
Search for a specified string Ignore Case: Set IC |
N |
Displays the next matching position of the searched string |
:/s/old/new |
New for first old in one line |
: s/old/new/g |
Replace all old in a row with new |
:%s/old/new/g |
Replace all strings in the file with old as new string |
:%S/OLD/NEW/GC |
Ask the user to confirm each replacement when making a full-text replacement |
: n1,n2s/old/new/g |
Replace all two rows with replace |
6. Revocation and anti-revocation
Command |
Role |
U |
Revoke |
Ctrl + R |
Anti-revocation |
7, indentation and anti-indentation
Command |
Role |
Shift + > |
Indent Right |
Shift + < |
Indent left |
8. Page turn
Command |
Role |
Ctrl + b |
Turn up one page |
Ctrl + u |
Turn up half a page |
Ctrl + F |
Turn down one page |
Ctrl + D |
Turn down half a page |
9. Window operation
Command |
Role |
: Split |
Split a window |
: New |
Create a new window |
: Close |
Close the current window |
: SF + filename |
Open a file in a new window |
: Only |
Keep the current window only |
: Set Mouse=a can be manipulated by mouse
: Set
Use the action:
1. View Vimsrc file location: Echo $VIM
2, block operation: Ctrl + V into the visual mode, press the arrow keys to select
3,: e! Do not save the case, reopen the
To open a new file: E filename, then use CTRL + ^ for file switching
Use the system clipboard: In normal mode, press SHIFT + INSERT to copy the contents of the system Clipboard into VIM or use the middle mouse button
Vim shortcut keys