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 ripgrep or 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 todo

Show line numbers and filename only:

rg -n TODO

Search only certain file types:

rg TODO -g "*.cpp" -g "*.hpp"

Include hidden and ignored files (like .gitignore):

rg TODO --hidden --no-ignore

Literal string search (not regex):

rg -F a+b*c

List only matching file names:

rg -l TODO

Show files that do not match:

rg -L TODO