Three modes: command mode, input mode, last line mode.
Command mode: Control the movement of the cursor, and can copy, paste, delete and search the text.
Input mode: normal text input, entry.
Last Line Mode: Keep or exit the document, and set the editing environment.
Three modes switch between each other:
Every time you run the Vim editor, it enters the command mode by default.
Commonly used shortcut keys in command mode:
Ctrl + f page down
Ctrl + b page up
G move to the last line of the file
gg move to the first line of the file
N(Number) + Enter Move N lines down
/keywords to find keywords down
? Keyword Look up keywords
# Find the keyword where the cursor is located backward from the cursor
* Find the keyword where the cursor is located from the cursor forward
dd deletes an entire line
ndd delete the cursor down n lines
yy copy the line where the cursor is
nyy copy the cursor position down n lines
p Paste the copied data on the line below the cursor
P Paste the copied data on the line above the cursor
command mode conversion input mode
i inserts to the left of the current character
I Insert at the beginning of the current line
a Insert to the right of the current character
A Insert at the end of the current line
o Insert a new row below the current row
O Insert a new row above the current row
In the input mode, Esc must be used to exit the input mode before the content can be saved.
:w save data
:q exit file
:wq save and exit the file
:q! Force quit
:w file name is equivalent to save as
:set nu display line numbers
:set nonu don't show line numbers
: Integer Jump to new line