ArticleDirectory
- Search options
- Cut/copy/paste
K
H l left and right
J lower
^ Move to the first non-space character in the row
W. Move a word forward and treat it as a word.
W. Move a word forward without using symbols or punctuation as a word
B. Move a word backward and treat the symbol or punctuation as a word.
B. Move a word backward and do not treat symbols or punctuation as words.
0 to the beginning of the line
$ To the end of a row
Gg to top
G to the end of the page
Line number + G jump to specified line
CTRL + G query the current row information and current file information
FX jumps to X of the row to the right (X can be any character)
FX jumps left to X (X can be any character)
TX and FX are the same. The difference is to jump to the character before X.
TX and FX are the same. The difference is that
C-B scroll up
C-F scroll down
C-u scroll up half screen
C-d scroll down half screen
C-Y: Scroll up a row
C-e scroll down a row
Exit vi
ZZ: Exit VI and save
: Q! : Exit VI, do not save
: WQ: Exit VI and save
Repeated operation
.: Repeat the previous operation
Auto-completion
C-N matches the next keyword
C-P matches the previous keyword
Insert
O: open a new line under the cursor and place the cursor at the beginning of the new line to enter the insert mode.
O: Same as above, above the cursor.
A: Enter the insert mode after the cursor.
A: Same as above, before the cursor.
R: Enter the replacement mode until you Press ESC.
Set XXX: Set the xxx option.
Delete in VI
X: Delete characters under the current cursor
DW: Delete the remaining part of the word after the cursor.
D $: Delete the remaining part of the row after the cursor.
DD: Delete the current row.
C: The function is the same as D. The difference is that after the delete operation is completed, the insert mode is entered.
Cc: also deletes the current row and then enters the insert mode.
Change character
RX: change the character under the current cursor to X (X is any character )~ : Change the case sensitivity of characters under the current cursor
Keyboard macro operations
Qcharacter: starts recording macros. character is any character from A to Z.
Q: Terminate the recording macro.
@ Character: Call the macro recorded previously
Restore misoperation
U: undo the last command
U: Corrected previous operations on this row
CTRL + R: redo
Operate frame in VI
Add frame in C-w c-n
C-w c-c reduce Frame
C-W switching Frame
C-w c-r swap two frames
Search in VI
/+ String: you can find the corresponding string in the current file.
Continue to search for the same string, press N or/(enter). To continue searching in reverse direction, press SHIFT + N.
To reverse search, use? Replace/
. * [] ^ % ~ $ It has a special meaning in VI. If you need to find it, you should add the Escape Character "\"
%: Find matching parentheses.
S/old/new/G: replace old with new. If no G exists, replace only one.
If you want to ask the user for each replacement, use the GC option.
Some options for searching are highlighted.
: Set hlsearch to highlight
: Set nohlsearch disable highlight
: Nohlsearch disables the highlighted items that have already been set.
Incremental search
: Set incsearch to set incremental search
: Set noincsearch disable incremental search
Block operations in VIM
Vim supports up to 26 clipboard
Use V, C-V, and V to select a block, copy it with Y, and paste it with P.
YY copies the current entire row
Nyy copies the content of N rows starting from the current row.
Ayy copies the current row of the cursor into register
The AP pasted the content in register a at the cursor position. If a is a complete row copied with YY, paste it under the row where the cursor is located.
The AP pastes the content in register a before the cursor position. If a is a complete row copied with YY, paste it on the row where the cursor is located.
Ay [motion]
Ay $ copy the cursor to the end of the row and save it in register
Ayft copies the cursor to the first letter T in the current row and saves it in register.
If all the preceding commands can remove a, Y and P work on the Untitled register (all the objects D, C, X, and Y are saved here ).
Cut/copy/paste
All deleted content is automatically saved and can be pasted with the p key.
Tips
PairCodeAuto format Gg = G