Vim usage notes
**************************************** ****************************************
---- 1 ---- SHIFT + Z in normal mode, equivalent to: WQ
**************************************** ****************************************
---- 2--VIM: insert incremental numbers
For example, you want to change a from row 1 to row 17 to A1, A2, and A3.
: let i = 1 | 11,17g/\<a\>/s//\=i/ | let i+=1
: Help: G. You can view the help of the G command.
: [Range] G [lobal]/{pattern}/[cmd] ()
Execute the ex Command [cmd] (default ": P") on
Lines within [range] Where {pattern} matches.
H: S
: [Range] s [ubstitute]/{pattern}/{string}/[flags] [count]
For each line in [range] replace a match of {pattern}
With {string }.
When the {string} starts with "\ =" it is evaluated as an expression, see
| Sub-replace-expression |. You can use that for any special characters.
After performing a search operation, VIM remembers the pattern and offset (± nlines) used this time ). You only need to specify the direction (and/or a new offset) for the next use.
H ::/
/{Pattern} [/] The next line where {pattern} matches *:/*
\/The next line where the previusly used search
Pattern matches
/{Pattern} forward searches for the specified pattern
/Use the previous mode and offset mode for forward lookup, that is, when the matching mode is null, it indicates that the previous matching is successful.
: [Range] s [ubstitute]/{pattern}/{string}/[flags] [count]
For each line in [range] replace a match of {pattern}
With {string }.
When the {string} starts with "\ =" it is evaluated as an expression, see
| Sub-replace-expression |. You can use that for any special characters.
After performing a search operation, VIM remembers the pattern and offset (± nlines) used this time ). You only need to specify the direction (and/or a new offset) for the next use.
H ::/
/{Pattern} [/] The next line where {pattern} matches *:/*
\/The next line where the previusly used search
Pattern matches
/{Pattern} forward searches for the specified pattern
/Use the previous mode and offset mode for forward lookup, that is, when the matching mode is null, it indicates that the previous matching is successful.
: [Range] s [ubstitute]/{pattern}/{string}/[flags] [count]
For each line in [range] replace a match of {pattern}
With {string }.
When the {string} starts with "\ =" it is evaluated as an expression, see
| Sub-replace-expression |. You can use that for any special characters.
**************************************** ****************************************
---- 3--Vim jump to the header file in the. c file and open the corresponding header file
Move the cursor over the header file:
GF
You can open the corresponding header file.
CTRL + O
Returns to the. c file.
**************************************** ****************************************
---- 4 ---- Vim multi-tag switching
: Tabnew [++ opt option] [+ cmd] Create a new tab for the specified file
: Tabc close the current tab
: Tabo: Close all other tabs.
In standard mode:
GT and GT can be directly switched between tabs.
**************************************** ****************************************
---- 4 ---- Vim Multi-Window
: New is a new horizontal split window by default. Another command is: Split.
Vertical Split. Command: vsplit
Press Ctrl + W twice in a row, and VIM automatically jumps to the next window.
Or press Ctrl + W and then J/K to locate the window.
**************************************** ****************************************
Replace multiple spaces with one space.
In a regular expression: * Indicates matching 0 or multiple characters that match exactly before it
:%s/ * / /g
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
**************************************** ****************************************
Data favorites
Compiling the vimrc configuration file
Some advanced replacement techniques in VIM
Vim
Tips for replacing commands in