vim comment several lines at once

 

Here I am showing couple of examples to comment several line at once using vim editor.

I have a text file with 15 line in it.

Examples:

To comment from line number 5 to 10:

:5,10s/^/#/g

To comment 5 lines after line number 5 and including line number 5:

:5,+5s/^/#/g

To comment all lines:

:%s/^/#/g
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s