Vim text Some line comment, replace

Source: Internet
Author: User

Key operation:
Note: Ctrl + V enters column edit mode, moves the cursor down or up, marks the beginning of the line that needs comment, then presses the uppercase I, then inserts the comment, such as "#", and then presses ESC, which is all commented.
Delete: Press v First, enter visual mode, select the number of columns in the landscape (such as "#" comment symbol, need to select two columns), then press ESC, then press CTRL + V to enter the column editing mode, move the cursor down or up, select the comment section, and then press D to delete the note symbol (#).

PS: Of course, it is not necessarily the shell's annotation "#", it can be "//", or any other character; Vim does not know what is an annotation, all characters.

Use the Replace command:
:% s/^/\/\//g Add//Number comment at the beginning of all content
: 2,50 s/^/\/\//g Add//Number comment at the beginning of 2~50

: 2,50 s/^\/\///g Delete//number at the beginning of 2~50

Replace blank line:

: 1, $s/^$\n//g

Line capital of each row adds a string:%s/^/the string to insert

Add a string to the end of each line:%s/$/the string to insert

Explain:

% represents subsequent actions on each line of the edited file
$ represents the end of a line
^ Represents the beginning of a line

Note: The column reproduced from ZXX

Vim text Some line comment, replace

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.