Linux--vim Common operations
Insert command:
Command |
Role |
A |
Insert the word specifier where the cursor is located |
A |
Insert at the end of the line where the cursor is |
I |
Insert in the word match either the cursor |
I |
Insert before the cursor is in the row |
O |
Insert a new line under the cursor |
O |
Insert a new line on the cursor |
Locate command:
Command |
Role |
: Set Nu |
Set line number |
: Set Nonu |
Cancel line number |
Gg |
To the first line |
G |
To the last line |
NG |
to Nth row |
: N |
to Nth row |
$ |
Move to end of line |
0 |
Move to the beginning of the line |
Delete command:
Command |
Role |
X |
Delete the character at the cursor location |
Nx |
Delete n characters after cursor location |
Dd |
Delete the row where the cursor is located, ndd delete n rows |
Dg |
Delete the line from the cursor to the end of the file |
D |
Delete the cursor at the end of the line |
: n1,n2d |
Delete a specified range of rows |
copy and cut commands:
Command |
Role |
Yy |
Copy when moving forward |
Nyy |
Copy Current row n rows |
Dd |
Cut when moving forward |
Ndd |
Cut the current row n rows |
P,p |
Paste at the current cursor row or line |
Replace and Cancel commands:
Command |
Role |
R |
Replaces the character at which the cursor is located |
R |
Start with the cursor where you know to press ESC to end |
U |
Cancel the previous action |
Search and search Replacement commands:
Command |
Role |
/string |
Search for a specified string Ignore case when searching: Set IC |
N |
Searches for the next occurrence of the specified string |
:%s/old/new/g |
Replace all specified strings |
: n1,n2s/old/new/g |
Replace a specified string within a certain range |
Save and Exit Commands:
Command |
Role |
: W |
Save changes |
: w New_filename |
Save as specified file |
: Wq |
Save changes and exit |
Zz |
Shortcut keys, save changes and launch |
: q! |
Do not save changes to exit |
: wq! |
Save changes and exit (file owner and root can be used) |
Import command execution result: R! Command
Define shortcut keys: Map shortcut Trigger command
Example:: Map ^p i#<esc>
: Map ^b 0x
Continuous line Comment: n1,n2s/^/#/g
: n1,n2s/^#//g
: n1,n2s/^/\/\//g
Replacement: AB mymail [email protected]
Linux--vim Common operations