Jan
3

VIM Trick: How to Comment Multiple Lines

If you need to comment out lines of text inside VIM, you can try this trick:

(Enter command mode in VIM)
:40,105s/^/#/g

This will insert the # character at the beginning of each line starting from line number 40 to line number 105.

If you cannot see the line numbers, do this:

(Enter command mode in VIM)

:set number

To remove the lines:
:set nonumber

This is quite handy if you need to comment out lines of codes in a script.

Related Posts

2 Comments to “VIM Trick: How to Comment Multiple Lines”

  • Mohan January 20, 2011 at 5:22 am

    It is quite useful, tahnks for the trick.

  • Oscar November 11, 2011 at 3:58 pm

    Rai,

    This is helpful indeed it makes administration easier… ;p

Post comment

CommentLuv Enabled

Powered by 1and1.comGlobat Webhosting Earn with Your BlogAdvertise @ PinoyTux

Search PinoyTux

Subscribe to Email Feeds

Enter Email Address:

Blog Lounge

Popular Posts

Recent Posts

Drop your Card Here

Recent Comments

Site Stats