Saturday 18 November 2017

Multi Line Commenting in Vim

Comment and Uncomment Multiple lines in Vim

As we know, Vim is very powerful command line editor. Lets learn how to comment/uncomment multiple lines in one go using Vim shortcuts.

To comment the multiple lines:

  1. Press Control+v to activate Visual Block mode.
  2. Select the lines, you want to comment by pressing up and down keys. (It will look like one word selected on each line, but it does not matter)
  3. Now press Shift+i that is capital i to enter in INSERT mode.
  4. Now type the comment character according the code language for example (#, %)
  5. Now press esc. The comment character will appear on each line, you selected.
Hurray! we learnt multi line commenting in Vim. Lets learn multi line uncommenting in Vim now.

To uncomment the multiple lines:

  1. Press Control+v to activate Visual Block mode.
  2. Select the character, you want to remove to uncomment the lines, by pressing up and down keys.
  3. Press d button to delete that character.
Awesome! We uncommented the multiple lines in one go.

Keep Learning, Keep Sharing!

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel