Vim Three modes: General mode , edit Mode , Command mode .
* General mode: when you vim filename to edit a file, it is normal mode to enter the file. . In this mode, you can do the following actions: Move the cursor up or down, delete a character, delete a row, copy , paste one line, or multiple lines .
*  Edit mode: In general mode, it is not possible to modify a character, only to edit mode from general mode into edit mode, just you press a key ( i,i,a,a,o,o,r,r " When you enter edit mode, it appears on the bottom line of the screen "INSERT or replace " from edit mode back to normal mode just click on the top left of the keyboard esc key to
* Command mode: in general mode, enter ":" or "/" to Enter command mode . In this mode, you can search for a character or a string, or you can save , replace , exit , Displays line numbers and so on .
Move the cursor in general mode
h or LEFT ARROW key |
The cursor moves one character to the left |
J or DOWN ARROW key |
Move the cursor down one character |
K or UP ARROW key |
Move the cursor up one character |
L or RIGHT ARROW key |
The cursor moves one character to the right |
CTRL + F or PageUp key |
The screen moves forward one page |
CTRL + B or PageDown key |
The screen moves backward one page |
Ctrl + D |
The screen moves forward half a page |
Ctrl + u |
The screen moves back half a page |
+ |
Cursor moves to the next column of non-whitespace |
- |
Cursor moves to the previous column of non-whitespace |
n Spaces (n is number) |
Press the number n and then press a space, the cursor moves to the right n characters, and if the number of characters is less than N, the cursor continues to move from the downstream to the right, up to n |
0 (number 0) or shift+6 |
Move to the beginning of the bank |
Shift+4 |
That ' $ ' moves to the end of the bank. |
H |
Cursor moves to the top row of the current screen |
M |
The cursor moves to the center line of the current screen |
L |
Cursor moves to the bottom row of the current screen |
G |
Cursor moves to the last line of text |
NG (n is number) |
Move to the nth row of the text |
Gg |
Move the first line with the text |
N Enter (n is number) |
Move the cursor down n rows |
Find and Replace in general mode
/word |
Look for a string named word after the cursor, and when you find the first word, press "n" to continue searching for a |
? word |
Look for a string named word before the cursor, and when you find the first word, press "n" to continue searching for the previous |
: n1,n2s/word1/word2/g |
Find the Word1 string in N1 and N2 and replace it with WORD2, and you can change the "/" to "#" |
: 1, $s/word1/word2/g |
From the first line to the last line, look for word1 and replace it with WORD2 |
: 1, $s/word1/word2/gc |
Plus the role of C is to require user confirmation before replacing |
Copy, paste, delete in general mode
X,x |
X to remove one character backwards, X to delete one character forward |
NX (n is numeric) |
Remove n characters backwards |
Dd |
Delete the line where the cursor is located |
NDD (n is numeric) |
Delete the next n rows where the cursor is located |
d1g |
Delete all data from the row to the first row of the cursor |
Dg |
Delete all data from the row to the last row of the cursor |
Yy |
Copy the line where the cursor is located |
Nyy |
Copy down n rows from the line where the cursor is located |
P,p |
P The copied data is pasted from the next line of the cursor, and p is pasted from the cursor line |
y1g |
Copy all data from the row to the first row of the cursor |
YG |
Copy all data from the row to the last row of the cursor |
J |
To combine data from the row of the cursor with the next row |
U |
Restore past operations |
Edit mode
I |
Inserts a character match either the current character |
I |
Inserts a character at the beginning of the current line |
A |
Inserts a character specifier the current character |
A |
Inserts a character at the end of the current row line |
O |
Insert a new row below the current line |
O |
Insert a new row on the current line |
R |
Replace the character with the cursor, replacing it only once |
R |
Always replace the character of the cursor until you press ESC |
Command mode
: W |
Save the edited text |
: w! |
Force Save if Text property is read-only |
: Q |
Exit vim |
: q! |
No edits or edits are not saved exit |
: Wq |
Save, exit |
: e! |
Restore a document to its original state |
Zz |
If the document does not change, then do not store away, if the document has been changed, then the store left, equivalent to: Wq |
: w [filename] |
Save the edited document as FileName |
: R [FileName] |
Reads the contents of the filename document below the line where the current cursor is located |
: Set Nu |
Show line numbers at the beginning of each line |
: Set Nonu |
Cancel line number |
N1,N2 w [filename] |
Save the contents of N1 to N2 as filename for this document |
:! Command |
Temporarily leave Vim to run a Linux command, for example:! Ls/home temporarily lists the files under the/home directory and then prompts you to press ENTER to return to VIM |
Reprint: http://blog.csdn.net/lovesomnus/article/details/45117735
Interested in Java communication please dabigatran: 79124001
Linux Text Editing Tool vim