Linux Basics - VI and VIM

The text editing tool
vim below the vi command line is an enhanced version of vi. The
command vim can start the vim editor.
Generally, vim can be used in the form of vim + target file path.
If the target file exists, vim will open the file.
If the target file does not exist, create a new one. The file

vi has three modes: command mode, insert mode and ex mode.
Any mode can return to command mode by pressing esc key
. Press "i" key in command mode to enter insert mode, and press esc in insert mode to return to In the command
mode, press ":" to enter the ex mode, and in the ex mode you can save, modify and exit
the command mode. The commonly used commands are as follows:
i Insert text before the cursor
o Insert a new line below the current line
dd Delete the entire Line
u undo the last operation
yy copy the current line
n+yy first press 5, then press yy, it is to copy the contents of the 5 lines
p paste
r replace the current keyword
/find the keyword

EX mode
: w save the current modification
: q exit
: q! Force quit
: x Save and exit
: setr number Display line number:!
Execute a system command and display the result
: sh switch to the command line, use ctrl+d to switch back to vim

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326078807&siteId=291194637