Three modes of vim
- Command mode
- Insert mode
- Lastline mode: generally used for saving files, setting line numbers to find characters, etc.
Insert mode command:
There are many ways to enter the insert mode. Vim attaches great importance to the action of the cursor. If it is an empty text, you can directly i
press the key ESC
exit the insert mode.
Other insert mode commands can be remembered For having iosa.
i before the cursor, enter insert mode --------------- a after the cursor, enter insert mode
i at the beginning of the line, enter insert mode --------- ------- A is at the end of this line, enter insert mode
oAdd a new line after this line and enter insert mode
OAdd a new line before this line and enter insert mode
s deletes the current character and enters insert mode
S deletes all text in the current line and enters insert mode
Common commands in bottom line mode:
Enter bottom line mode, enter in command line mode:
:
w 名称
Save with the file name (if the file already exists, you can directly w):
wq
save the file and exit vim:
q
Do not save the file and exit vim:
q!
Force quit vim without saving the file
Appears in the lower left corner of the screen: Indicates that the bottom line mode has been entered
Save the file related:
Display line number: set number
Cancel display line number: set nonu
It can be understood as set no number
to locate a certain line: 行号
, as shown in the figure below
Search string /字符串
Copy n line to m line: n,my
then press p Copy, note that there is a y after m
to cut n lines to m lines:n,md