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.
May 13, 2008 at 6:46 am |
[...] VIM – Comment blocks of code « Not So Frequently Asked Questions [...]
May 19, 2009 at 10:20 am |
Capital “I” puts me simply into an insert mode.
January 1, 2010 at 7:09 pm |
That’s OK. Just type something, don’t worry that it will display just on the beginning of one line, when you press Esc, it will be added to all of the selected lines (some version of vim needs to press e.g. move key after Esc to display it).
October 6, 2009 at 6:06 am |
[...] Via var linkwithin_site_id = 38479; (function () { var elem = document.createElement('script'); elem.type = 'text/javascript'; elem.src = 'http://www.linkwithin.com/widget.js?rand=' + Math.random(); document.getElementsByTagName('head')[0].appendChild(elem); })(); [...]