1, VIM fast move the cursor to the beginning and end of line
1 Press the Home key on the keyboard to quickly move the cursor to the beginning of the line. Use ^ (SHIFT + 6) or 0 (number 0) in command/Normal mode to return to the beginning of the line. ^ is moved to the first non-empty character.
As the following illustration shows, the home key and 0 are moved to the beginning of the line:
^ (SHIFT + 6) is to move to the first non-empty character (not the tab or space)
2 Press the END key on the keyboard to quickly move the cursor to the tail of the line. Use $ (SHIFT + 4) in command mode to return to the end of the line. You can add numbers to indicate the number of rows moved, for example, "1$" to indicate that the cursor is moved to the end of the current line, and that "2$" is moved to the end of the next line, and so on.
2. Move the cursor up and down (KJHL)
H,NH: Moves one character or n characters to the left
L,NL: Moves one character or n characters to the right
K,nk: Moves up one or n rows.
J,NJ: Moves down one or n rows.
GG: Moves the cursor to the beginning of the first line of text.
G: Move the cursor to the beginning of the last line of text.
: Set number shows line numbers
: linenumber move to line linenumber, such as: 10 to move to line 10th
3. Move the cursor in Word
W,NW: The cursor moves backwards 1/n a word and falls on the first character of the word.
B,NB: The cursor moves forward 1/n a word and falls on the first character of the word.
E,ne: Similar to W, only the cursor falls on the tail character.
Ge,nge: Similar to B, the cursor falls on the tail character.
If you want to ignore the punctuation word, use uppercase, respectively, w,b,e, and divide word by blank or space.
4. Delete Operation
x: Deletes a single character at the cursor
X: Deletes the character before the cursor.
DW,DNW: If the cursor is on the first character of the word, delete the/n word and the cursor is positioned on the first character of the next word. And the word after the space to delete together. If the cursor is not on the first character of the word, it is removed from the character to the next space, and the cursor is positioned on the first character after the space.
Daw,dnaw: The cursor is at any point in a word, deleting the word and the space that follows it. Consecutive characters before the cursor and consecutive characters and spaces after the cursor are deleted.
De,dne: Deletes a word and the cursor moves to the end of the word, which is the space.
D0: Delete to beginning of line
d$: Deletes all characters of the line after the cursor is deleted.
DD: Cut/delete Row ndd-> cut/delete n rows. 3DD means to delete 3 rows. The cursor is in rows and the latter two lines.
DNL: Delete n characters to the right
DNH: Delete n characters to the left, the following figure is the effect after entering d4h, these n characters include a space.
5, copy, paste, undo Operation
YY: Copy nyy: Multiple-line replication->5yy means copy 5 rows
P: Paste, paste copied or cut text
U: Undo the last action.
CTRL + R: Entering replacement mode
U/shift+u: Undo all operations on the line.
6, turn the page
Ctrl + F means page Down
Ctrl + B means page up
Ctrl + D turn down half a page
Ctrl + U turn up half page
7, character substitution and character lookup
R: Enter R, and then enter a character that replaces the character at the cursor with this character. A single character replacement.
After you enter replace mode, return to normal mode after replacing one character
For example:good-> input RH, become hood.
R: After entering replace mode, you can replace multiple characters consecutively and return to normal mode via the ESC key.
Ctrl + [is equivalent to pressing the ESC key.
* : Find the cursor's word backwards.
#: Look forward to word in the cursor
/xx[ab]x: Find Xxax and XXBX
/^\n: Finding Blank Lines
/xx\|yy: Find xx and yy
: S/old/new: Replaces the first old of the row with the cursor with new.
: s/old/new/g: Replaces all the old of the row with the cursor with new.
:%S/OLD/NEW/GC: Replaces all old in the file with new. The c:confirm represents a confirmation before each replacement.
8. Save Operation
: w-> Save changes, do not exit.
: Wq-> Save changes, and launch.
: e! -> do not save changes, do not exit, equivalent to no modification, reopen the file.
: q! -> do not save changes, exit the edit file.