Ripgrep is a fast text file search tool
grep is a ubiquitous command-line tool for searching plain-text data sets for lines that match a regular expression.
Ripgrep
is a modern alternative to grep that is designed to be faster and more efficient at recursive text file searches common to code developers.
Ripgrep is used internally by
VS Code
for its search functionality.
Install ripgrep with:
- Windows:
winget install BurntSushi.ripgrep.GNU - macOS:
brew install ripgrep - Linux:
apt install ripgrepor similar
The rg command is used to invoke ripgrep, and it supports a wide range of options for customizing search behavior.
Examples:
Search for the term “TODO” in all .cpp files in the current directory and its subdirectories:
rg "TODO" --glob "*.cpp"Case-insensitive search:
rg -i todoShow line numbers and filename only:
rg -n TODOSearch only certain file types:
rg TODO -g "*.cpp" -g "*.hpp"Include hidden and ignored files (like .gitignore):
rg TODO --hidden --no-ignoreLiteral string search (not regex):
rg -F a+b*cList only matching file names:
rg -l TODOShow files that do not match:
rg -L TODO