Vim has three modes, namely command mode, edit mode and last-line mode

Text editing is not possible when we are in command line mode, we can enter edit mode by clicking one of several letters

I insert, that is, insert before your cursor position

I insert, at the beginning of the line where your cursor is

A append, append after your cursor position

A append, append at the end of the line where your cursor is

O Insert, a new line will be created next to your cursor for insert editing

O Insert, a new line above your cursor will be created for insert editing

R replace, make a substitution at the location of your light change, when the character is replaced, it will go back to command mode

R replace, perform multiple substitutions at the position of your cursor, and when the character is replaced, the cursor moves one bit

When we enter the edit mode, we can edit content in it, just like the Notepad in Windows. When we finish editing, press Esc key to return to the command mode, and press: to enter the last line mode to save and exit

: In command mode, press: to enter the last line mode. In the last line mode, the following operation is performed to save and exit

Q is just exit, assuming you haven’t changed it

q! Forcible exit, if you modify the file, forcible exit is not saved

Wq is save and exit

wq! Forced save exit is used for read-only files, which can only be performed by root and owner

Set nu sets the line number for the text

To set nonu is to remove the line number from the text

1, 5s /dog/cat/g is to replace all the strings dog from the first to the fifth lines with the string cat, where g means all

2 m 5 is moving the second row after the fifth row

2 co 5 copies the second line after the fifth line

1,3 d is delete the first to third rows

U is for the deleted part of the reply

R /etc/passwd Is used to read the /etc/passwd file. You are advised to create a new file to read the passwd file

The following describes some common operations in command mode

G jumps directly to the bottom line of the text

Gg jumps to the top line of the text

2G jumps to the beginning of the second line of text, where the 2 can be changed as needed

2gg also jumps to the beginning of the second line of text

H is for moving the cursor to the left

L is for moving the cursor right

J is for moving the cursor down

K is for moving the cursor up