Move
0: Number 0, move to the beginning of the cursor
$: Move to the end of the line where the cursor is
Insert
I insert from the cursor without overwriting the contents of the following
A prompt insert from the next word in the cursor position
A is inserted at the end of the line where the cursor is located
o Insert a new line from the next line in the row where the cursor is located
O Insert A new line from the previous line on the row where the cursor is located
R replaces the character at the cursor
R replaces the character at the cursor and remains, overwriting the contents of the following
Delete
x Delete one character backwards, like "delete"
X Delete one character, similar to "backspace"
DD Delete the line where the cursor is located
Ndd:n is a number, starting at the cursor position and deleting n rows down
Copy and paste
YY the line where the cursor is copied
Nyy N is a number, starting at the cursor position and copying n rows down
P Paste to the next line in the cursor position
Search Check
: A, bs/word1/word2/g A, B is the number of rows, which means searching for word1 between rows A through B, and substituting Word2
: 1, $s/word1/word2/g from the first line to the last row, look for word1 and replace with Word2
: 1, $s/word1/word2/gc from the first line to the last row, find the word1 and replace with WORD2, the replacement will appear prompt, to the user to confirm whether to replace
N: Repeat the previous search action, search down
N: Search Up
Save
: Wq Save Exit
: e! To restore a file to an unedited state
ZZ Save exit
Q! Force quit does not save
: W Save As
: R edits data, reads the data into a file, and displays the following line at the current cursor position
: A, B w save the contents of row A to line B as
U : Revert undo last Action
Ctrl+r: Repeat Last Action
. : Repeats last action
: Set NU Displays line number
: Set Nonu Cancel display
Global Display line number: Directly modify/ETC/VIMRC write set Nu and save exit
Current User display: Modify the current user's VIMRC file to add set Nu
Fills the contents of another file into the current file
: R/path/to/somefile
In the vim editing process, you can execute commands
:! COMMAND
Syntax highlighting on/off
: Syntax on/off
Found text highlighting
: Set Hlsearch
: Set Nosearch
Vim Common operation