vim – How to quickly comment out entire sections of code

Go to the first line and type the following:

^ to go to the beginning line. (probably want the top too)
Ctrl + Alt + V (to enter block highlight mode)
#j (where # is the number of lines to be commented out) Or just move the cursor manually.
I (capital i)
Press the esc key.
They should all be commented out now, with c++ style comments.

Leave a Reply

You must be logged in to post a comment.