Article source: www.huaweicloud.com/articles/bl…

The original link: blog.csdn.net/CSDN1013/ar…

Description of buttons available for general mode

Cursor movement, copy and paste, find and replace, etc
H or arrow to the left The cursor moves one character to the left
J or down arrow Move the cursor down one character
K or up arrow The cursor moves up one character
L or arrow to the right The cursor moves one character to the right
[Ctrl]+[f] Moving the screen down one page is equivalent to the Page Down button
[Ctrl]+[b] Moving the screen down one page is equivalent to the Page Up button
[Ctrl]+[d] The screen moves down half a page
[Ctrl]+[u] The screen moves up half a page
+ The cursor moves to the next line that is not a space character
The cursor moves to the line above the non-space character
n “N” indicates a specific number, such as 10. Pressing the number followed by the space bar will move the cursor to the right of the n-space character on the line.
0 or function key Move to the first character on the line
$or function key Move to the last character on the line
H The cursor moves to the first character in the top line of the screen
M The cursor moves to the first character of the line in the center of the screen
L The cursor moves to the first character in the bottom line of the screen
G Move to the last line of the file
nG Move to line NTH of the file. 20G
gg Move to the first line of the file
n[Enter] Move the cursor down n lines

If you want to move multiple times, such as down 30 lines, use the 30J or 30↓ key combination. Other similar | mobile direction key combination


Find and replace
/word Look down for a string named word. Such as/mark
? word Look up for a string named Word. Such as/mark
n Repeat the previous lookup. For example, enter /mark and press n to search down the character string mark
N Reverse the previous lookup
: n1, n2s/word1 word2 / g Look for word1 between lines N1 and n2 and replace word1 with word2
:1,$s/word1/word2/g Look for word1 between the first and last lines and replace word1 with word2
:1,$s/word1/word2/gc Look for word1 between the first and last lines and replace word1 with word2. Before the replacement, prompt the user to confirm whether the replacement is required

Delete, copy and paste
x,X In a line, x is one character removed backward and x is one character removed forward
nx Delete n consecutive backward characters
dd Delete the entire line where the cursor is
ndd Deletes n rows down from the cursor position
d1G Deletes all data up to the first row where the cursor is located
dG Deletes all data up to the last line where the cursor is
d$ Deletes the last character from where the cursor is
d0 Deletes the first character in the line from where the cursor is
c Delete multiple rows, such as 10 rows down [10cj]
yy Copy the line where the cursor is located
nyy Copy the cursor n rows down
y1G Copies the data from the cursor row to the first row
yG Copies the data from the cursor row to the last row
y0 Copies all data from the character where the cursor is located to the beginning of the changed line
y$ Copy all data from the character where the cursor is located to the end of the changed line
p,P P indicates that the copied data is pasted on the line below the cursor, p indicates that the copied data is pasted on the line above the cursor. For example, the cursor is now at line 20 and 10 rows of data have been copied. After you press P, the 10 lines will be pasted after the original 20 lines, that is, the 21 lines will be pasted first. But if you press P, line 20 becomes line 30
J Combine the cursor row with the data on the next row
u Undo the previous operation
[Ctrl]+r Redo the last operation
. This is a decimal point. Repeat the meaning of the previous operation.

   

General mode –> Description of available buttons for Edit mode

I, I Enter Insert mode (Insert mode). I indicates that the cursor is inserted from the first non-space in the current line
a, A Enter Insert mode: A indicates that the cursor is inserted from the next character, a indicates that the cursor is inserted from the last character in the current line
o, O Enter Insert mode. O indicates that a new line is inserted from the line next to the current cursor. O indicates that a new line is inserted from the line above the current line
r, R Repalce mode r will only Tijuana the cursor on the character once; R replaces the cursor problem until Esc is pressed
[Esc] Exit edit mode and return to general mode

Copy and paste

Delete all After pressing esc, press GG first (to the top), then dG
Copy all After pressing ESC, press GG, then ggyG
Highlight all of them After pressing ESC, press GG and then ggvG or ggvG
Single copy After pressing ESC, then YY
Single line to delete After pressing ESC, then DD
paste After pressing ESC, then P
Copy to the paste board Once all highlighted, CTRL + Shift + C,

Vim can only paste 50 lines: Edit ~/. Vimrc in the current user’s home directory (if it doesn’t exist, create a new file) and add a line :set viminfo=’1000,<500

It doesn’t really matter why ‘1000 ‘is entered. The main thing is to enter <500, which sets the number of lines the register can hold, i.e., the maximum is 500.