Vim notes and materials favorites

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.