"Linux" vim Editor-bulk comments and anti-annotations

Source: Internet
Author: User

[-]

    1. Vim Editor---Bulk comments and anti-annotations
      1. Method Piece Selection Mode
        1. Inserting comments
        2. Cancel Comment
      2. Method Two replace command
        1. Bulk annotations
        2. Cancel Comment
        3. Example Demo
Vim Editor---Bulk comments and anti-annotations

When writing code using VIM, it is often necessary to use bulk annotations and counter-comments for a piece of code. The following is a brief description of its operation.

Method Piece Selection Mode

Insert Comment:

Enter virtual mode with V

Use the up and down keys to select the number of lines you want to comment

Press Control+v (win below ctrl+q) to enter the column mode

Press the larger "I" into insert mode, enter the comment "#" or "//" and press ESC immediately (two)

Uncomment:


Ctrl + V Enter block selection mode, select the comment symbol for the beginning of the line you want to delete, note//To select two, then press D to delete the comment

Method Two replace command

Bulk Comment:


Use the following command to add comments at the beginning of the specified line:

: Starting line number, ending line number s/^/comment/g

Uncomment:


: Starting line number, ending line number s/^ comment//g

Example Demo:


Add//comment on line 27-30

: 27,30s#^#//#g

Delete//comment on line 27-30

: 27,30s#^//# #g


Add # comments To line 10-20

: 10,20s/^/#/g

Delete # comments on line 10-20

: 10,20s/^/#/g

Note that in the example, the delimiter used is the opposite symbol, and if the match//is used #作分隔符这样不需要对/as Escape, save the number of inputs.

"Linux" vim Editor-bulk comments and anti-annotations

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.