Vim
Vim is a powerful full-screen text editor, which is the most commonly used text editor on Linux/unix , and its function is to create, edit and display text files.
Note:vim does not have a menu, only commands
VI [filename ] Enter command mode
WQ Exit Command mode
Input i a O from the command mode into insert mode
Press ESC to exit Insert mode and enter Command mode
Input: Enter edit mode by command mode
Enter command to end run with enter command mode
Insert command
Command |
Role |
A |
Insert after the character of 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 |
Position 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 the first n characters at the cursor location |
Dd |
Delete Row of cursor,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 the following n rows of the current row |
Dd |
Cut when moving forward |
Ndd |
Cuts the current n rows |
P, p |
Paste at the current cursor row or line |
Replace and Cancel commands
Command |
Role |
R |
Cancels 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 |
Search and search Replacement commands
command |
|
/string |
search for the specified string, Ignore case when searching :set ic |
n |
|
:%s/old/new/g |
:n1,n2s/old/new/g |
|
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 exit |
: q!
|
Do not save changes to exit |
: wq! |
Forcibly save the changes and exit (the file owner and root can be used) |
This article is from the "djh01" blog, make sure to keep this source http://djh01.blog.51cto.com/10177066/1690340
Linux Text editor vim