Consider the text
A
B
# C
# D
Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D? ap
or ip
with the cursor on any of those four lines will select all four, since there is not a blank line between C and D.
Use case: git commit messages. For example:
Added glob tests; bugfix in fnmatch
Run `CTEST_OUTPUT_ON_FAILURE=1 ctest .` to see the inputs for glob tests
that fail.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
If I put the cursor on the Run...
line and wrap it with gqap
, all of the #...
comment lines get wrapped in:
Run `CTEST_OUTPUT_ON_FAILURE=1 ctest .` to see the inputs for glob tests
that fail. # Please enter the commit message for your changes. Lines
starting # with '#' will be ignored, and an empty message aborts the
I would like gq<something>
to select only the non-#
lines and wrap them. The only workaround I can think of so far is v/^#<CR>jgq
, which seems rather tedious.
Another use case:
Being able to distinguish comment lines from non-comment lines would also help me select Doxygen comments before functions:
/// Comment here A
/// More comment here B
void do_something_interesting() { C
} D
Same deal: I'd like to be able to select A+B without C+D or vice versa.