Original article: Vim tips-quick move
1. move by Screen
(1) The most common commands are as follows:
CTRL + f // move the screen forward (to the greater direction of the row number). If you want F to represent forward
CTRL + B // move the screen backwards. If B is used, it should be before.
CTRL + D // move the half screen forward and D indicates down
CTRL + u // move the half screen backward and U indicates up
CTRL + E // move the entire file content up in the editing window.
CTRL + y // move the entire file content in the editing window down one line.
Note: press Ctrl and then press F.
(2) use Z to reposition the screen.
Z + press ENTER // to move the current line to the top of the screen.
the following is an extension command:
100z + press ENTER // move the 100th rows to the top of the screen. Remember to enter 100z and press enter again.
Z. // Move the current row to the center of the screen without carriage return. Remember
Z-// Move the current row to the bottom of the screen, same as above, without carriage return
2. move by search
In fact, for a source Program file, we usually need to find a variable or function name, the most effective method is to quickly move by text search.
/pattern // The forward search mode. pattern indicates the content to be searched.
? Pattern // Backward Search mode
N // repeat the previous search (in the direction greater than the row number)
N // repeat the previous search in the opposite direction
3. move by row number
Ng // move to row N. Note that G is in uppercase. Enter N, Shift + G in lower-case mode, and G in upper-case mode.
(For example, 100th GB can be quickly located at rows in the source program.CodeIt must be useful .)
CTRL + G // display the current line (not a move command)
G // move to the end of the file, Enter Shift + G in lower case mode, and press g in upper case mode.
4. move by the cursor
Left: H
Lower: J
Upper: K
Right: l
Start of the next row: + // shift to the top of the file '+'
First line of the previous line :-
Beginning of the current row: 0
Move the cursor to the starting position of the current row, that is, the first non-blank character of the current row: ^
End of the current row: $
Next word: W, W // W: move the cursor to the right. The cursor stays at the beginning of the next word. W: move the cursor to the right. The cursor stays at the beginning of the next word (even if there is a punctuation between the two words ).
Last word tail: E, E // E: move the cursor to the last character position of the current word (or the next word); E: Same as E, only use space characters as the separator of words.
First word: B, B // B: move the cursor to the left. The cursor stays at the beginning of the next word. B: move the cursor to the left. The cursor stays at the beginning of the next word (even if there is a punctuation between the two words ).
Current screen first line: H
Last line of the current screen: l
Center of current screen: m
FX // move to the right to x
FX // move to the left to X
TX // move to the right before X
TX // move from left to X
(Note: X indicates the characters in the preceding four commands)
; // Semicolon, used together with F and t, repeat once
, // Comma, used together with F and t, repeat once in the opposite direction
Mark text replacement
Mqq // use the string QQ to mark the current cursor position
'Qq // move to the place marked by QQ (the top of the key on the left of the Number 1 key)
'Qq // move to the beginning of the line marked by QQ (single quotation marks)
''// Move to the beginning of the row at the first position on the current row (two single quotes after the cursor moves)
"// Move to the last position of the current row (after the cursor moves) -- 1 double quotation mark (test fails)