Chris Mueller

Easy Comments in VIM

May 7, 2008

Lately I have been coding a lot in C++. Earlier this week I added two lines to my .vimrc file, and they have proven incredibly useful:

" comment/uncomment lines
map C 0i//[CTRL+ESCAPE]j
map T 0xxj

Typing C in visual mode comments out that line, and typing T uncomments the line.

There are many ways to make comments quickly in vim, but this mechanism seems well-suited to my style. The exact keystrokes are modified version of commands I found elsewhere on the net, and there are many others with their own ideas of how to make comments in vi, so obviously I cannot take credit for this idea.

Comments

Bryan writes:
hoi hoi

© cm