I’m looking for a way to preview the results of a grep search within files as well as fold the output when there are multiple matches in the same file.
helm-projectile-ag
is my current grepping tool but doesn’t seem to offer such a facility, unless I haven’t read the docs well enough.
My issues are:
-
It can present a lot of hits in the same file it but lists each one separately. A good option would be to fold the output when there are multiple matches, then I can use the Tab keep to expand the fold and scan through the previews and even edit them right away.
-
The search panel is modal. It doesn’t create a result buffer which you can save and then return to later to continue to select files to edit. Once you lose focus it is gone. It doesn’t even seem to retain the search term so you can use it later.
-
It would be nice to have a window that shows the actual CLI command passed to the search utility. I see them once in a while but it would be good to show them up front or make them easily accessible.
Do any of the project grep tools or helm-projectile-ag
itself offer such features?
Consult is what you are looking for: https://github.com/minad/consult In particular try consult-ripgrep
For previewing file, press `C-c C-f` to enable `follow-mode`. Then, a buffer is opened whenever you move your highlight to a file.
For saving buffer, Helm offers an action to save:
By default, you press `tab` to access action menu.
I’m trying it and get can’t the action menu.
Is this in a new version of helm-projectile-ag?
Try embark and the embark export along with consult (or maybe helm). With consult for example you can hit Tab to jump to the next file. Embark export can export the grep results, which can even be saved - and re-opened later and browsed with grep mode enabled :)