ripgrep
Notes on ripgrepripgrep
ripgrep is a command line tool that allows for quickly searching exact matches to regex patterns.
Default use is rg <query> [PATH]
Using it as a grep replacement to pipe to fzf, using in Vim as line search for wiki
- Was looking into how I might be able to truncate the context around a match in a line. Every now and again there will be a match in a very long line, and using
rgon its own will print the entire thing. When used withfzf, the actual match typically cant be seen becausefzfjust uses one line to show the preview, and the match is likely way beyond the front portion of the line. After doing some digging, I found-M {n} --max-columns-previewoptions forrg, but they don’t really do what I want. Those options just say, if the current matched line is longer thannbytes long, cut off the tail after thenbytes. So these options pretty much do exactly whatfzfdoes, which is unhelpful. There does not appear to be a way of doing this is in ripgrep alone. A small workaround, when using in conjunction with fzf, is just typing that text out in the preview to actually show a match. You can then keep searching from there. This is the functionality implemented in the current backlink and unlinked reference commands.