Download vim and vim
Vim
Vim-related knowledge is accumulated and is continuously updated.
Common Key Mode
n1,n2s/word1/word2/g
Search for word1 between line n1 and line n2 and replace it with word2.
1,$s/word1/word2/g
Search for word1 from the first row to the last row and replace it with word2.
N[Enter]
Move n rows down
- 0: Move to the last character of the row
- $: Move to the first character of the row
- G: Last line
- Gg: First Line
- X & X: x is equivalent to [Del], and X is equivalent to [Backspace]
- Dd: delete this row
- Yy: Copy this row
- Nyy: Copy n rows down
- P & P: p is pasted to the next row, and P is pasted to the previous row.
- U: Restore the previous operation
- /: Search
Switch to the command line
- :! Command temporarily leaves the display result of Executing command
- Set nu display row number
Environment Settings and records
There are many parameters set in the vim environment. If you want to know the current setting value, you can enterset all
But there are too many options to set. Here we will list some simple settings that are commonly used.
You can also use the configuration file to intuitively define the vim operating environment we are used. The overall vim setting value is generally placed in the/etc/vimrc file. However, it is not recommended to modify it directly. Recommended File Modification~/.vimrc
This file (which does not exist by default, please manually create it) and include the desired setting value.
Set hlsearch "High Brightness anti-white set backspace = 2" class at any time use the backspace key to delete set autoindent "automatic contraction set rshort" class shows the status of the last row set showmode "the status of the row in the lower left corner set nu "row number set bg = dark" show different background colors syntax on "syntax highlighting
Block Selection
When you press v, V, or [Ctrl]-v, the position where the cursor passes will start to be reversed. The y key can be copied, And the d key can be deleted.