Simple way to use vim under Linux

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 ipress the key ESCexit the insert mode.
storage
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)

: wqsave the file and exit vim

: qDo 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
insert image description here
Save the file related:
Display line number: set numberCancel display line number: set nonuIt can be understood as set no number
to locate a certain line: 行号, as shown in the figure below
insert image description here
Search string /字符串
Copy n line to m line: n,mythen press p Copy, note that there is a y after m
to cut n lines to m lines:n,md

Guess you like

Origin blog.csdn.net/qq_42573052/article/details/126948485