1.Vim Introduction
Vim is a powerful full-screen text editor, the largest text editor on the Linux/unix, which is created, edited, and displayed as text files.
Vim has no menu, only commands.
2.
3. Insert command
Command |
Role |
A |
Insert in the word specifier the cursor |
A |
Insert at the end of the line where the cursor is |
I |
Insert in the word match either the cursor |
I |
Insert at the beginning of the line where the cursor is |
O |
Insert a new line under the cursor |
O |
Insert a new line on the cursor |
4. Positioning commands
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 |
5. Delete command
Command |
Role |
X |
Delete the character at the cursor location |
Nx |
Delete the following n characters of the cursor |
Dd |
Delete Row of cursor, NDD delete n rows |
Dg |
Delete the line of the cursor to the end of the file line |
D |
Delete the cursor at the end of the line |
: n1,n2d |
Delete a specified range of rows |
6. Copy and cut commands
Command |
Role |
Yy |
Copy when moving forward |
Nyy |
Copy the following n rows of the current row |
Dd |
Cut when moving forward |
Ndd |
Cut the following n rows of the current row |
P, p |
Paste at the current cursor row or line |
7. Replace and Cancel commands
Command |
Role |
R |
Replaces the character at which the cursor is located |
R |
To replace a character from where the cursor is, press ESC to end |
U |
Cancel the previous action |
8. Save and Exit commands
Command |
Role |
: W |
Save changes |
: w filename |
Save as specified file |
: Wq |
Save changes and exit |
Zz |
Shortcut keys, save changes and exit |
: q! |
Do not save changes to exit |
: wq! |
Save changes and exit (file owner and root can be used) |
9. Tips
1) Import command execution result: r! command
2) Define shortcut key: Map Shortcut Trigger command
Example: Map ^p i#<esc>
Map ^b 0x
3) Continuous line comment: n1,n2s/^/#/g
: n1,n2s/^/#//g
: n1,n2s/^/\/\//g
4) Replace
: AB MyMail 123456@qq.com
Text editor Vim