Press I to enter edit mode
Press I (I in uppercase) to enter edit mode and the cursor jumps to the beginning of the cursor position
Press O to start editing from the next line of the cursor
Press O (capital O) to start editing from the previous line on the row where the cursor is located
Press A to start editing from the back of the cursor position
Press A (capital a) to start editing from the end of the line where the cursor is located
Second, the command mode
In command mode, enter the content that/+ needs to search, such as/DNSMASQ, to find DNSMASQ
Command mode input? + What you need to search for, look up
Input format in command mode: The number of start lines to replace, the number of end lines to replace/content to replace/target content to replace/g (s = start substitution; g = global substitution, replace all; no g means replace only the first character content)
Cases:
: 1,100s/dnsmasq/qwerty/g//Replace all DNSMASQ in line 1th-row 100 with QWERTY
: 1, $s/dnsmasq/qwerty/g//Replace all DNSMASQ in the file with a QWERTY ($ means all in the file)
: 1, $s/\/etc/\/hosts/qwerty/g//Replace all/etc/hosts in the file with a QWERTY
: 1, $s #/etc/hosts#qwerty#g//Use the # symbol to separate the/etc/hosts
: 1,[email protected]/etc/[email protected]@g//Use the @ symbol to separate the/etc/hosts
(Tip: Press the colon + UP ARROW key to find the last command you used)
: Wq Save Exit
: wq! Force Save exit
: W Save File
: w! Force save File
: Q exit
: q! Force exit
: Set NU Displays line number
Set Nonu does not display line numbers
: Nohl does not display highlighting
: x After changing files: X and: Wq effect
Third, Vim practice
Vim edit mode, command mode, and practice