VIM – Comment blocks of code

Mark the area which is to be commented using the *blockwise* visual mode (CTRL-V, in Windows this is CTRL-Q).

Press I (capital i) and write the text you want to prepend to each line of the selected block, e.g. %.

Then press ESC and the text will be inserted to the left of each line of the selected block.

VIM – Comment blocks of code « Not So Frequently Asked Questions

Author: WladyX on 13 May, 2008
Category: General, Scripts, Vim

Leave a Reply

Last articles