1. Install Vim
Yum Install-y vim-enhanced
2. Common commands
Display to the first few lines of the file
Vim +10/etc/init.d/iptables (shown to line tenth of the file)
Show the number of file lines
: Set Nu
VIM Tri-Medium mode
General mode
The movement of the cursor
Up or down key
JK (up and down); HL (around)
Ctrl+f (Page down); ctrl+b (Page UP)
GG (Enter the first line of the document); Shift+g (enter the last line of the document)
Shift+4 (Enter the end of the line); 0 or shift+6 (enter the beginning)
Copy, cut, paste
Delete
X key (delete backward); Shift+x (delete forward)
Shear
Pressing the P key after delete copies the entire line of the deletion to the position below the cursor; Shift+p is glued to the cursor
Revoke
U key (can be revoked 50 times)
Anti-revocation
Ctrl+r
Copy
Yy
Visual mode
V (the document can be manipulated in visual mode)
Edit mode
Input characters (i, I, A, A, O, O can be entered in edit mode)
I cursor position into the editing mode, I line into the editing mode, a after the cursor into the editing mode, a cursor line end into the editing mode, O cursor line into the editing mode, O cursor line into the editing mode
Exit edit mode
ESC (exit from edit mode to normal mode)
Command mode
: Wq (Write and exit)
: Set Nu (show line number)
/iptables (search iptables)
? Iptables (search iptables)
: 1, $s/iptables/iptables/g (replace IPTABLES in the full-text row with IPTABLES, and replace globally)
%=1,$ (Full text)
Substitution symbols can also be written as #/etc/sysconfig/#111 #, meaning the same
Vim/etc/init.d/iptables
VI!$ = Vi/etc/init.d/iptables
This article is from the "Coarse bread" blog, make sure to keep this source http://culiangmianbao.blog.51cto.com/10475024/1770444
Vim common operation and use method