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:
[/
v
]/
These will:
- The first will jump to the start of a block comment (the slash in /*)
- The second will turn on select mode
- 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. :)