It's fast indeed. And I can't help keeping promoting the combination with fzf :) For those who want to try it out, this is a Powershell function but the same principle applies in any shell. Does ripgrep then puts fuzzy searching in the resulting files+text on top while showing context in bat:<p><pre><code> function frg {
$result = rg --ignore-case --color=always --line-number --no-heading @Args |
fzf --ansi `
--color 'hl:-1:underline,hl+:-1:underline:reverse' `
--delimiter ':' `
--preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" `
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
if ($result) {
& ($env:EDITOR).Trim("`"'") $result.Split(': ')[0]
}
}
</code></pre>
There are other ways to approach this, but for me this is a very fast way of nailing down 'I now something exists in this multi-repo project but don't know where exactly nor the exact name'<p><i>edit</i> this comes out of <a href="https://github.com/junegunn/fzf/blob/master/ADVANCED.md">https://github.com/junegunn/fzf/blob/master/ADVANCED.md</a> and even though you might not want to use most of what is in there, it's still worth glancing over it to get ideas of what you could do with it
I use ripgrep with the Emacs packages project.el (comes out of the box) and dumb-jump (needs to be installed). This may not be the most popular way of using rg but I have been very pleased with the overall experience. All it takes is running package-install to install the dumb-jump package and configuring the following hook:<p><pre><code> (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
</code></pre>
The Xref key sequences and commands work fine with it. If I type M-. (or C-u M-.) to find definitions of an identifier in a Python project, dumb-jump runs a command like the following, processes the results, and displays the results in an Xref buffer.<p><pre><code> rg --color never --no-heading --line-number -U --pcre2 --type py '\s*\bfoo\s*=[^=\n]+|def\s*foo\b\s*\(|class\s*foo\b\s*\(?' /path/to/git/project/
</code></pre>
The above command shows how dumb-jump automatically restricts the search to the current file type within the current project directory. If no project directory is found, it defaults to the home directory.<p>By the way, dumb-jump supports the silver searcher tool ag too which happens to be quite fast as well. If neither ag nor rg is found, it defaults to grep which as one would expect can be quite slow while searching the whole home directory.
What's interesting is that ripgrep now also powers VS Code search with a Node.js wrapper.<p><a href="https://www.npmjs.com/package/@vscode/ripgrep" rel="nofollow noreferrer">https://www.npmjs.com/package/@vscode/ripgrep</a>
I've been using ripgrep for about 2 years now and I find in indispensable. The main reason I switched from grep was ease of use. From the README: "By default, ripgrep will respect gitignore rules and automatically skip hidden files/directories and binary files." Typing `rg search_term directory` is much better than the corresponding grep command, but the speed improvement is also a nice bonus.<p>Random other helpful flag I use often is -M if any of the matches are way too long to read through and cause a lot of terminal chaos. Just add `-M 1000` or adjust the number for your needs and the really long matches will omit the text context in the results.
And this may still be true in 2023, but the problem is that most of the parallelized grep replacements (e.g. ripgrep, ag, etc.) are <i>SO</i> much faster than grep that the much small speed differences between them doesn't provide much of a basis for differentiating them.<p>I use ag (typically from inside Emacs) on a 900k LOC codebase and it is effectively instantaneous (on a 16 core Ryzen Threadripper 2950X). I just don't have a need to go from less than 1 second to "a bit less than less than 1 second".<p>Speed is not the defining attribute of the "new greps" - they need to be assessed and compared in other ways.
well... it is not faster than qgrep :) even though the way both work - differs greatly, and even though qgrep is based on re2 - the speed comes from the presence of index. but then I wonder why people forget the qgrep option, since with large file stores it makes much more sense to use qgrep AND indices, rather than always go through all the files.<p>this above all true UNLESS you need multi-line matches with UTF8, where ripgrep is not so fast, because it needs to fall back to the other PCRE2 lib
I switched from from ripgrep to ugrep and never looked back. It's just as fast, but also comes with fuzzy matching (which is <i>super</i> useful), a TUI (useful for code reviews), and can also search in PDFs, archives, etc.<p>The optional Google search syntax also very convenient.<p><a href="https://ugrep.com" rel="nofollow noreferrer">https://ugrep.com</a>
I searched in portage, and it seems there is another version working also with other documents like PDFs and doc.<p><a href="https://github.com/phiresky/ripgrep-all">https://github.com/phiresky/ripgrep-all</a>
Using Ripgrep via Consult [1] in Emacs is bliss. It's like the rg+fzf thing that some have made, but all inside Emacs. I use the `consult-ripgrep` command <i>all the time</i>, and sometimes I use it to make project-wide edits too! Workflow is search with `consult-ripgrep` -> export results to buffer -> edit buffer -> commit edits back to files. Details at [2] (includes video of me working it)<p>[1]: <a href="https://github.com/minad/consult#grep-and-find">https://github.com/minad/consult#grep-and-find</a>
[2]: <a href="https://lambdaland.org/posts/2023-05-31_warp_factor_refactor/" rel="nofollow noreferrer">https://lambdaland.org/posts/2023-05-31_warp_factor_refactor...</a>
Semi off-topic, I've coded a ncurses-frontend to navigate and filter grep-like results which might be of interest to some of you: <a href="https://github.com/gquere/ngp2">https://github.com/gquere/ngp2</a>
Would be nice if ripgrep was drop in compatible with grep. I'd feel like a dick writing a shell script for other people to use and forcing them to install a new grep
I love ripgrep for the speed and the more sane defaults. I use it nearly every day.<p>For those just using it to search through a codebase, don't forget -F for string literals.