Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request enables the
:Ack
family of commands to work on visual selections. If the user marks an area of text and types:Ack
, the contents of the visual selection will be used as a search term. The other two cases, an:Ack
that uses the word under the cursor, and:Ack <term>
which uses the given argument as a query, still work.The text is given as-is, which means if there are special characters in there, the results might be unexpected (say, marking
char* variable
would consider the*
a special character). Still, this has often been a useful shortcut for me, even if it does break down for more complicated expressions (sometimes, just one<cword>
is not enough).Note that this also fixes an issue I've (just) noticed with
:AckWindow
and, I thnk,:AckHelp
-- if you use them without arguments, taking the word under the cursor, they don't work. That's because the helper functions concatenate the empty argument list with a list of files, soa:args
is no longer empty and the code doesn't take the word under the cursor into account. If this PR is not accepted, I can make a separate pull request with just this fix. Incidentally, the reason I can't test:AckHelp
properly is that I seem to have so many plugins that the combined resulting command-line is too long to process correctly :). But I can't think of a good fix to that.I'd like to add a note to the documentation about the visual mode search, but I'm not sure where to do it. I think the documentation doesn't mention the "word under the cursor" functionality, so maybe we should add that somewhere as well?
I also have two additional features I'd like to propose, but it'll take me some time to prepare pull requests.