Monday, April 7, 2008

Quick Uncomment

This tip was contributed by my friend (and expert Vim user), Christopher Suter. BTW, if anybody else has a tip they would like to contribute, just send me an email via tinymountain at gmail dot com.

To uncomment a /* */ - style block comment, put the cursor on the beginning or ending tag - whichever is closest - and in normal mode, do %dd``dd

this sequence jumps to the matching 'brace' (/* or */) deletes that one, then jumps to the previous jump point, which is of course the first 'brace.' you can replace dd with xx if the braces are not on their own lines for example:

/* this.commentedInvocation(); */

A really handy idiom that is great for large block-commented code.

Thanks Chris!

1 comment:

Will said...

dd will delete the entire line. Perhaps you want xx or 2x.