First, edit mode, command mode
In general mode, enter: or/To enter command mode. In this mode, you can walk a character or string, save, replace, exit, display line number, etc.
/word: Look for a string after the cursor word, press N to go back to search
? Word: Look for a string before the cursor word, press N to go back to search
: n1,n2s/word1/word2/g: Find word1 between N1 and N2 rows and replace with Word2, no G replaces only the first word1 of each row
: 1, $s/word1/word2/g: replace all word1 in the document with Word2, and no G replaces only the first word1 of each row
: w: Save text
: Q: Exit vim
: w!: Force save, under root user, even if the text is read-only can be saved
: q!: Forced exit, all changes not in effect
: Wq: Save and exit
: Set Nu: Display line number
: Set Nonu: line number not displayed
Second, vim actual combat
[[email protected] ~]# vim/tmp/1.txt
Root:x:0:0:root:/root:/bin/bash
Bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/ Nologin
Adm:x:3:4:adm:/var/adm:/sbin/nologin
Lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
Sync:x:5:0:sync :/sbin:/bin/sync
Shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
Halt:x:7:0:halt:/sbin:/sbin/halt
Mail:x : 8:12:mail:/var/spool/mail:/sbin/nologin
Operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100: Games:/usr/games:/sbin/nologin
ftp:x:14:50:ftp user:/var/ftp:/sbin/nologin
nobody:x:99:99:nobody:/:/sbin/ Nologin
Systemd-network:x:192:192:systemd Network management:/:/sbin/nologin
Dbus:x:81:81:system message bus :/:/sbin/nologin
Polkitd:x:999:997:user for Polkitd:/:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/ Sbin/nologin
sshd:x:74:74:privilege-separated ssh:/var/empty/sshd:/sbin/nologin
chrony:x:998:996::/var/ Lib/chrony:/sbin/nologin
Davery:x:1000:1000::/home/davery:/bin/bash
~
~
~
~
Linux centosvmware vim edit mode, vim command mode, VIM practice