edit mode for 5.5:vim:
Edit mode: (enter the following command into edit mode): You can edit the contents of the file:
Command mode: (Press ESC to enter command mode),
supplemental command: in command mode
:hi: Highlight:
:nohi: The highlight is not displayed:
" x ": Save exit, and Wq the difference is that when entering a file is not edited, the use of this command does not change the file atime.
Command mode replace command: We replace the size letter A with the lowercase letter a
[Email protected] ~]# cat 1.txt #输入文件的内容
Aaaaaaaaaaaaa
Aaaabbbbbbcc
Dddaacccacc
[[email protected] ~]# vim 1.txt
:1, $s/a/a/g #用vim进入后, and then replace with this command, the output is as follows:
[Email protected] ~]# cat 1.txt
Aaaaaaaaaaaaa
Aaaabbbbbbcc
Dddaacccacc
There are three alternative formats, depending on the situation:
[Email protected] Text original content @ Replace content @g
s# text original content # replaced content #g
s/text original content/replace content/g
Vim's Practice:
Responsible for/etc/passwd to the desktop:
#cp/etc/passwd./1.txt
Move up or down 10 characters to the left and right:
10k 10j 10h 10l
Move the cursor to line 49:49G
Move to the last line of text:
G
Move to the first line of text:
Gg
Number of root occurrences in the search file:
/root Press N to select the next:
Restore previous action: U
Replace the root of the entire file with Toor.
1, $s/root/root/g
The use and practice of Day17-vim (II.)