Vim's commands are too many to forget, so I decided to sort out the various commands of VIM, including vim insertion and deletion, cursor Movement, Multi-window editing, copy-and-paste, find-and-replace, and some common commands
Delete operation
DD Delete When moving forward
NDD deletes n rows starting at the current line (including the current row)
DW Delete to end of word
NDW from the cursor to the end of the third word (the field is not strictly distinguished)
NdW from the cursor to the end of the third word (strict field distinction)
You can also DNW or DNW
X Delete a character at the cursor
D0 Delete to the beginning of the line
d^ Delete to the beginning of the line (keep spaces and tabs at the beginning of the line)
d$ Delete to end of line
D Delete to end of line (same as d$ command)
D Enter Delete 2 rows
Ctrl+u deletes the text entered under input mode.
D Delete to end of line
DL deletes the current character (same as x command function)
DB Delete to the beginning of a word
DW deletes the end position of a word with a space separator
DB Delete to the beginning of a word with a space separator
d7b Delete to the beginning of the first 7 words with spaces as separators
D4) Delete to the end of the fourth statement
D (Delete to the beginning of a statement
d) Delete to the end of a statement
d{Delete to the beginning of a paragraph
nd{the nth paragraph position before the start position of the current paragraph is deleted
D/text deletes the position of the typeface specified in the text from "text", moving forward until the next occurrence of the typeface (but not including the typeface)
The DFC deletes the position from the text where the character "C" appears, moving forward until the next occurrence of the character (including the character) between the contents
DTC deletes the current row until the next character "C" appears between the contents of the position
DL delete content until the last line on the screen
DH deletes the contents of the first line until the screen
DG delete content until end of work buffer
D1G Delete content until the working buffer starts
C Delete and enter insert MODE
CC Deletes the current line and then enters insert MODE
Move cursor
J Move Cursor Down
K Move Cursor up
H move the cursor to the left
L MOVE the cursor to the right
^ Move to the first non-whitespace character of the line
W move forward a word and use the symbol or punctuation as a word
W move forward a word without a symbol or punctuation as a word
b Move one word backwards to treat the symbol or punctuation as a word
B Move backward one word and do not treat the symbol or punctuation as a word
(The cursor moves to the beginning of the sentence
The cursor moves to the end of the sentence
{cursor moves to the beginning of a paragraph
The cursor moves to the end of the paragraph
H cursor moves to the top line of the screen
M cursor moves to the middle line of the screen
L move the cursor to the last line of the screen
0 to the beginning of the line
$ to end of line
GG to the top of the page
G to end of page
Line number +g jump to the specified line
n+ cursor down n rows
N-the cursor moves up n rows
FX jumps right to the bank character X (x can be any character)
Fx jumps left to bank character X (x can be any character)
TX and FX are the same, the difference is jumping to the character X before Tx and FX are the same, the difference is jumping to the character x after
Ctrl-b Scroll up one screen
CTRL-F Scroll down one screen
Ctrl-u scrolling up half screen
ctrl-d Scroll down half screen
CTRL-Y scroll up one line
CTRL-E Scroll down one line
Mobile Code
J Merge the next line to the end of the current line
Choose
V Select a row (continue to move the cursor to select multiple lines)
Ctrl + V for selection of rectangular areas
Entry and exit
VI filename Opens or creates a new file and places the cursor at the beginning of the first
VI +n filename Opens the file and places the cursor at the beginning of nth
VI + filename Opens the file and places the cursor at the beginning of the last line
VI +/pattern filename Opens the file and places the cursor at the first string that matches the pattern
Vi-r filename has crashed during the last edit with VI and restored filename
VI filename ... filename open multiple files, edit them sequentially
ZZ exits VI and saves
: q! Exit VI, do not save
: Wq Exit VI and save
Insert
I enter insert mode
o Insert a new line in the next line
O insert a new line in the previous line
A enters insert mode after the cursor
A enters insert mode before the cursor
Find and Replace commands
R replaces one character
R enters replacement mode until ESC exits
/pattern search for pattern at the end of the file from the beginning of the cursor
Pattern is searched from the beginning of the cursor at the top of the file
N repeats the last search command in the same direction
N repeats the last search command in the opposite direction
% find pairs of parentheses
: S/p1/p2/g replaces all P1 in the current row with P2, and the GC option should be used to ask the user for each substitution
: N1,n2s/p1/p2/g replaces all P1 in line N1 to N2 with P2
: G/p1/s//p2/g replaces all P1 in the file with P2
:%s/p1/p2/g replaces all P1 in the file with P2
Rx Changes the character under the current cursor to X (any character x)
~ Change the case of characters under the current cursor
The. *[]^%~$ has a special meaning in VI, and the escape character "\" should be added if a lookup is needed.
Recall and recovery
U Undo Command
U fix previous action on this line
Ctrl+r Recovery (Anti-operation of U)
Multi-window editing
: Split xxx up and down windows open XXX file
: Vsplit xxx to open the xxx file in the left and right window
CTRL+WW cursor jumps to the next window
Copy and paste
Y Copy Selection
P Paste
YY Copy current entire row
Nyy to copy n rows starting at the current line
"+y copied to the system cut version
"+p paste from the system cut version
"+yg copied from the cursor to the end of the file and copied to the system clipping version
Some commands
. Repeat Last Command
: Set Hlsearch setting highlighting
: Set Nohlsearch off highlighting
: Set nu! Open line number
Not regularly updated, want to help ....
Vi/vim Command Collection