Enter edit mode
Lowercase i in the current word match either insert
Uppercase I inserts at the beginning of the line where the cursor is located
Uppercase O Inserts an edit line above the cursor
Lowercase o Inserts an edit line below the cursor
Lowercase a inserts a write after the cursor (A is an abbreviation for after)
Uppercase a inserts an edit at the end of the line where the cursor is located
Command mode
/After the cursor looks for a matching string---/word-----SHIFT + N to look up
? To find a specific string before the cursor----? Word
1,100s/user/xiaobo/g------1 to 100 lines, s means to start replacing, replace the User with Xiaobo, and G to replace global
Without G, only the first one will be replaced;
Replace AA with BB, find string and replace:%s/aa/bb/g-----% indicates all rows
Replace all: 1,S/ft p /x Iao bo / g?? s/ftp/xiaobo/g????? To show all the time to the last line;
/etc/hosts/xiaobo.com to replace the character/etc/hosts with xiaobo.com
1, $s/\/etc\/hosts/xiaobo.com/g
where \ is de-justified,/etc/hosts is recognized as a string
You can also write this:
1, $s #/etc/hosts#xiaobo.com#g
: 1, $s/dnsmasq/aminglinux/g
Note: 1. Replace ":" before adding "
2.$ that the end of the line can also be represented by a number, such as 1,100 for the first row to the 100th row
3. s means replacement
4.////Front two/middle write what to replace two/middle write what you want to replace
5. G global variable represents all
De-translation:
where/etc/hosts/need \ de-translation
or///change to # # # or @@@
Small knowledge:
: Wq and: X If the file modifies the same effect
If not modified: Wq will modify the mtime:x of the file without making any changes
Practice:
# Cp/etc/dnsmasq.conf/tmp/1.txt
#vim/tmp/1.txt
Do not highlight Nohl
(1) Move Down, right, left, and up 6 characters (6j 6l 6h 6k) respectively.
(2) Two pages (two times ctrl+f and Ctrl+b respectively) downward and upward respectively.
(3) Move the cursor to line 49th (49G).
(4) Move the cursor to the end of the line, and then move to the beginning (Shift+4, shift+6).
(5) Move to the last line of the 1.txt file (G).
(6) Move to the first line of the file (GG).
(7) Search for "DNSMASQ" in the file and count the number of occurrences of the string (/dnsmsq then press N).
(8) Replace the DNSMASQ from line 1th to line 10th with DNS (: 1,10s/dnsmasq/dns/g).
(9) Restore the previous action (U).
(10) Replace all the etc in the entire file with a CTE (: 1, $s/etc/cte/g).
(11) Move the cursor to line 25th, delete the string "ly" (25G then press L to move the cursor to the right to find "ly", press V to select, and press X).
(12) Restore the previous action (U).
(13) Delete line 50th (50G dd).
(14) Restore the previous action (U).
(15) Delete all contents of 第37-42 line (37G 6DD).
(16) Restore the previous action (U).
(17) Copy the contents of line 48th and paste it below line 52nd (48G yy 52G p).
(18) Restore the previous action (U).
(19) Copy the contents of the 第37-42 line and paste it onto line 44th (37G 6yy 44G P).
(20) Restore the previous action (press U).
(21) Move the contents of the 第37-42 line below line 19th (37G 6DD 19G p).
(22) Restore the previous action (press U).
(23) Move the cursor to the first line, the 1th line to the "#!/bin/bash" (First press GG, the cursor to the 1th line, and then press the letter A, enter the editing mode, and > Cursor to the end of the line, to modify the operation, after completion, press ESC).
(24) Insert a new line below line 1th and enter "# hello!" (Press O to enter edit mode, while the cursor goes down another line, enter "# hello!" )。
(25) Save the document and exit (press the ESC key and enter ": Wq").
Enter edit mode & VIM Command mode &vim practice