Vim treats the commented line as an empty line
I like to move through my code with paragraph movements {
and }
. Is there a way to get vim to treat lines that are commented out (lines containing only text or spaces with comments if easier) as empty lines? That way, I could move through the commented lines with paragraph movement, since I would have blank lines.
c / C ++ (although ideally I would like the solution to work with any syntax):
BLANK -> /* FOE DOC STRING
BLANK -> * ...
BLANK -> */
NOT-BLANK -> int foe()
NOT-BLANK -> {
NOT-BLANK -> int x = foo();
NOT-BLANK -> int y = fie(); /*
BLANK -> int z = bar();
NOT-BLANK -> */ x *= y;
BLANK ->
NOT-BLANK -> x = fee(x, fum(y));
NOT-BLANK -> return x;
NOT-BLANK -> }
BLANK ->
source to share
Move to the top or bottom of the comments with [/
or, ]/
respectively. (Note: [*
and ]*
also work.) The cursor can be placed either inside or outside of comments. So, at the top of C (++) files, I often came across] / to jump over header comments.
If you want to go to the beginning of the line int(foe)
in your example, I would use the following collation:
map ]/ ]/j0
This is much more efficient than using multiple paragraph jumps.
source to share