The best grep tool in the world; ripgrep
tl;dr; ripgrep (aka.
rg
) is the best tool to grep today.
ripgrep is a tool for searching files. Its killer feature is that it's fast. Like, really really fast. Faster than sift , git grep , ack , regular grep etc.
If you don't believe me, either read this detailed blog post from its author or just jump straight to the conclusion :
-
For both searching single files and huge directories of files, no other tool obviously stands above ripgrep in either performance or correctness .
-
ripgrep is the only tool with proper Unicode support that doesn’t make you pay dearly for it.
-
Tools that search many files at once are generally slower if they use memory maps, not faster.
I used to use
git grep
whenever I was inside a git repo and
sift
for everything else. That alone, was a huge step up from regular
grep
. Granted, almost all my git repos are small enough that regular
git grep
is faster than I can perceive many times. But with
ripgrep
I can just add
--no-ignore-vcs
and it searches in all the files mentioned in
.gitignore
too. That's useful when you want to search in your own source as well as the files in
node_modules
.
The
installation instructions
are easy. I installed it with
brew install ripgrep
and the best way to learn how to use it is
rg --help
. Remember that it has a lot of cool features that are well worth learning. It's written in Rust and so far I haven't had a single crash, ever. The ability to search by file
type
gets some getting used to (tip! use:
rg --type-list
) and remember that you can pipe
rg
output to another
rg
. For example, to search for all lines that contain
query
and
string
you can use
rg query | rg string
.