I’ve posted a follow up to this tip that details a quicker way to comment in vim by using a simple function. Check it out here.
From the “holy crap why didn’t I find this before” category…
When editing in vim, if you find you need to comment out a block of code, try the following:
Ctrl+v to enter Visual Block modeI to enter Insert mode before the first non-blank character on the lineEsc to get back to Normal mode.You can follow similar steps to uncomment the same block,Ctrl+v to
highlight the comment characters followed by x or any deletion command
to remove the comment.