Extending ag for vim
Hello vimmers,
I know many of you use external grep programs like ag, git grep or ack. ag --column can report the column number of the first match. But what about other matches on the line? AFAIK, none of the mentionned tools reports all matches on the line like :vimgrep /pattern/g can.
I would like to improve my grep workflow, so here's a fork of ag: https://github.com/inside/the_silver_searcher with the --vimgrep option added.
And here's an animated gif to show you what it does: http://i.imgur.com/dkbCuPr.gif
If you like this behavior, you can join the discussion on the github's pull request: https://github.com/ggreer/the_silver_searcher/pull/504
I hope you'll find this useful, Yann
Posted Sep 30, 2014, 11:57 AM UTC
This is great! Well done!
My only comment would be on the option name. IMO "vimgrep" doesn't make much sense if you look at ag as a command line independent from vim. The suggestions that come to me though are sadly not great, they tend to be too long (e.g. "allmatchesonline"). Maybe "allmatches" or "exhaustive" would work.
But this is mostly a detail. I'd certainly use it when it's available!
You made a point. I thought of --columns (notice the s). The reason I chose this name is that the --vimgrep option really formats the output for vim. I was inspired by the --ackmate option:
--ackmate: Output results in a format parseable by AckMate https://github.com/protocool/AckMate.
Vim uses the 'g' flag for the same meaning (in :sub). This old sed man page says it stands for global (which is what I assumed for vim but the help isn't explicit).
How about --global?
I wanted to suggest this as well.
--all-line-matches, --line-multimatch? I like --columns, except it's much too close to --column. --all-columns?
I'd call it vimmate then. It doesn't really make etymological sense, but OSS names never do.