Showing posts with label comment. Show all posts
Showing posts with label comment. Show all posts

Wednesday, June 3, 2009

Disable Comment Autocompletion

There are times when Vim's autocompletion of comments gets in my way more than it helps me. Fortunately, disabling comment autocomplete is easy. Just add the following to your vimrc.

au FileType * setl fo-=cro

Thursday, June 12, 2008

Comment Out Line Range

This is one of my favorite ex hacks. It's pretty old school and should work all the way back to the original Vi. This assumes your comment character is # (octothorpe), but would work just as well with // comments or any other line-wise comment character. Go to column zero of the first line you want to start your comment block on. Hit ma to set a mark. Now scroll down to column zero of the last line you want to comment out. Issue the following ex command:

:'a, . s/^/# /

That's it. It runs a substitute on the range from the mark stored in register 'a to the current line. Take note that you can specify ranges for any ex command using the same technique.