Cursor movement in vim command mode

I am really tired of using ↑ ↓ ← → in vim to move the cursor, so here is the common method of moving the cursor in vim.

Move cursor by character/line

In addition to the space bar and the arrow keys, the minus sign'-' (up), enter (down), h (left), j (down), k (up), and l (right) can also be used as arrow keys to move the cursor. If you need to move multiple characters or multiple lines at a time, you can enter a number before the arrow keys. For example, 7h means move 7 characters to the left, 3SPACE means move 3 characters to the right, and 2j means move 2 lines down. When the cursor line moves, the cursor moves to the same position on the next line. If there are not enough characters in the next line, it stops at the end of the line.

Minus sign (-): Move to the beginning of the previous line; when the arrow keys move up one line, it will move to the same column position in the previous line.

Plus sign (+): Move to the beginning of the next line; when the arrow keys move down one line, it will move to the same column position in the next line.

0: Move to the beginning of the line.

^: Move to the beginning of the line (the difference from 0 is that ^ will move the cursor to the position of the first non-blank character in the current line).

$: Move to the end of the line.

Move the cursor to a specific character

f/F finds the position where a specific character appears in the current line , f is to find the position of the next occurrence of a specific character, and F is to find the position of the last occurrence of a specific character. For example, input fa, which means to search for the first occurrence of a from the cursor position to the right. If it is found, the cursor will move to that position, and if it is not found, it will not move. Enter 3fc to find the position where the character c appears for the third time to the right of the cursor. Enter a semicolon (;) to repeat the last search command.

Move cursor by word

w/W Move the cursor to the first character of the next word. Punctuation marks are also regarded as a word. If the next word is on the next line, the cursor will search in the next line in turn. The difference between w and W is that W distinguishes words by spaces; if the punctuation and the word are concatenated, W will treat it as a word, and w still treats the punctuation as a single word for search. When the last word of the file is found, if it is searched again, the cursor will move to the last character. 13w means that the cursor moves 13 characters to the right.

b/B (begin) Move the cursor to the first character of the previous word. Punctuation marks are also regarded as a word. Other attributes are the same as the above w/W.

e/E (end) moves the cursor to the end character of the next word. Punctuation marks are also regarded as a word. Other attributes are the same as the above w/W.

Move cursor by sentence and paragraph

'(' and')' means to move the cursor to the beginning of the previous/next sentence respectively.

'{' and'}' respectively indicate to move the cursor to the beginning of the previous/next paragraph.

Move the cursor within the screen

H(home) Move the cursor to the beginning of the line at the top of the screen.

M(middle) Move the cursor to the beginning of the line in the middle of the screen.

L(lower) Move the cursor to the beginning of the line at the bottom of the screen.

Browse different parts of the working buffer

The text information currently edited by vim is in the working buffer area, and the information in the buffer area is displayed on the screen.

ctrl + d(down) Move the screen down by half of the screen information; add the number n before the command, which means the screen moves down by n lines.

ctrl + u(up) Move the screen up half of the screen information; add the number n before the command, which means the screen moves up n lines.

ctrl + f(forward) Move the screen down by one screen. In order to maintain continuity, the last two lines of the previous screen will be kept; the number n is added before the command, which means the screen moves down by n screens.

ctrl + b(backward) Move the screen up by one screen of information. In order to maintain continuity, the first two lines of the previous screen will be kept; the number n before the command means that the screen has moved up by n screens of information.

gg Go to the beginning of the text line in the buffer.

shift + g or G to go to the end of the buffer text line.

ngg / nG go to the nth row, for example, 5gg means go to the 5th row. 5G also goes to the fifth line. :5 plus carriage return is also the fifth line of the channel.

Guess you like

Origin blog.csdn.net/TomorrowAndTuture/article/details/111581269