I. Introduction of VIM
Installing Vim:yum install–y vim-enhanced
Vim mode: Normal mode, edit mode, command line mode
Second, VIM's shortcut keys
number 0 move to the beginning of line
shift+4 Move to end of line
shift+a Move to end of line and enter edit mode
o move to the next line and into edit mode
gg move to first line of text
shift+g move to the last line of text
n + shift+g Move to the first few lines
YY copy entire row
N+YY Copy N rows
P Paste
x Delete/cut cursor character
DD Delete/cut entire row
N+DD Delete/cut several lines
d$ Delete/Cut the contents (one line) after the cursor location
d^ Delete/Cut the contents (one line) before the cursor position
v Select character
R replaces the current character
u undo Last Action
/Find keyword (n key to switch in the found results, enter: Noh to cancel the search)
ctrl+r anti-revocation
pgup/pgdn up/down page
: W Save
: Q Exit
: q! Force exit, do not save changes
: x Save and exit, equivalent to: Wq
: Set NU displays line number
: Set Nonu cancel line number
:! System command, executes a system command and displays the result
: SH switch to command line, use CTRL + D to switch back to VI
: 1,10s/ip/ip/g text substitution (replace 1 to 10 lines)
:%s/ip/ip/g text substitution (replace all)% for entire document, s for replace, IP for original text, IP for replaced text, G for global substitution
:%S/IP/IP text substitution (replaces only the first one that appears in each line),
Note: the deletion of characters in the general mode is not really deleted, just put it on the Clipboard, press p can also be pasted out
Extension: How to indent multiple lines at once
In the VIM command mode press CTRL + V to enter the visual block mode, then move the cursor down, select the line to indent, then press shift+i, enter insert mode, hit 4 spaces, and finally press ESC, the corresponding line is automatically indented 4 spaces.
Linux Commands: Vim