In linux, vim is quite powerful. at the beginning, everyone who is familiar with it will feel useful but cannot remember what it is for. now let's take a look at the basic commands. (There is no time for today. add some examples in the search time) search: word search down to word? Word direction
In linux, vim is quite powerful. at the beginning, everyone who is familiar with it will feel useful but cannot remember what it is for. now let's take a look at the basic commands.
(We have no time today. please add some examples in time)
Search:
/Word search for word
? Word search up
N repeat the search string
N repeat the preceding string
: N1, n2s/word1/word2/g Replace word1 with word2 from line n1 to line n2
: N1, n2s/word1/word2/gc Replace word1 with word2 from line n1 to line n2 for confirmation.
: 1, $ s/word1/word2/gc Replace word1 with word2 from Line 1 to the last line for confirmation.
Copy and paste:
Yy copy the row where the cursor is located
Nyy copies the next n rows of the cursor
Y1G copy all
YG copy all cursor
Y0: Copy the cursor to the beginning of the line
Y $ copy the cursor to the end of the row
Delete:
X, X delete a character backward/forward
Nx deletes n consecutive characters backward
Dd deletes the row.
Ndd delete n rows
D1G delete all
DG delete the cursor to the end
D0 delete cursor to first line
D $ delete the cursor to the end of the row
Operation:
J. Combine the row where the cursor is located with the data of the next row into the same row
U recover the previous operation (equivalent to undo)
[Ctrl + r] redo the previous operation
. Redo the previous operation.
Command
:! Command
Summary:
Starting from 1 GB
Lowercase letters, capital letters, forward, and backward
Multi-file editing
Vim filename1 filename2
: Files
N switch to another file
Multiple windows
: Sp [filename]
This figure is painted by laruence. you can refer to it for reference (from laruence's linux private House dish)