How do I select the comment block under the cursor in vim?

Solution 1:

Assuming you're working with C++ block comments, these commands should do what you want:

  1. [/
  2. v
  3. ]/

These will:

  1. The first will jump to the start of a block comment (the slash in /*)
  2. The second will turn on select mode
  3. The third will jump to the end of a block comment (the slash in */), which selects the entire comment block.

I hope that helps!

EDIT: One note about using the lower case v instead of the upper case V. The upper case V will select entire lines while the lower case v will only select the text from the cursor's start position to the end position. Using the lower case v also means not having to hit the shift key. :)