Recommended Free Tools
From the directory you want to search, run rg 'pattern'. ripgrep searches recursively by default, returning matching lines and their file paths. To limit the search to a directory, add it: rg 'pattern' src/.
ripgrep is a line-oriented tool that recursively searches the current directory for a regular-expression pattern, as the project README explains. The commands below show how to adjust the pattern, file scope, and output when the default search is not quite right.
As an Amazon Associate I earn from qualifying purchases.
Start with a recursive search
Run a search from the directory that contains the files you want to inspect. For example, this searches the current directory and its eligible subdirectories for lines containing TODO:
rg 'TODO'
Pass a path to search only that location: rg 'TODO' src/. The pattern is a regular expression by default, so ordinary text works directly, while characters such as . have regex meaning.
#1 Best Overall
Choose how the pattern matches
Use the option that matches the kind of text you are looking for:
| Goal | Command | What it does |
|---|---|---|
| Ignore letter case | rg -i 'todo' |
Matches upper- and lowercase variants. |
| Use smart case | rg -S 'Todo' |
Ignores case unless the pattern contains an uppercase letter. |
| Match the text literally | rg -F 'a.b' |
Treats the pattern as a fixed string, so the period is not a regex wildcard. |
| Match a whole word | rg -w 'main' |
Restricts the match to the word rather than a longer string containing it. |
| Match across line breaks | rg -U 'firsts+second' |
Enables multiline matching so the pattern can span lines. |
The default regex engine does not support lookaround or backreferences. If a pattern requires either feature, consult the official FAQ and the linked regex documentation; ripgrep also has optional PCRE2 support for patterns that need a different feature set.
Limit which files ripgrep searches
A path, glob, or file type can narrow a search. Use a glob for a one-off filename rule and a type when you want a built-in group of file extensions.
| Scope | Command | Example use |
|---|---|---|
| Named directory | rg 'TODO' src/ |
Search only under src/. |
| Include a glob | rg 'fn run' -g '*.rs' |
Search paths matching the Rust-file glob. |
| Exclude a glob | rg 'TODO' -g '!*.min.js' |
Leave minified JavaScript files out. |
| Include a built-in type | rg -t rust 'TODO' |
Search files in ripgrep’s Rust type. |
| Exclude a built-in type | rg -T js 'TODO' |
Skip files in ripgrep’s JavaScript type. |
| List a built-in type’s file globs | rg --type-list |
See the types available in the installed version. |
You can define a type for one command with --type-add. For example, rg --type-add 'web:*.{html,css,js}' -tweb title searches files matching those extensions for title. A command-line type addition is not saved automatically.
Understand why a result may be missing
By default, ripgrep respects ignore rules from .gitignore, .ignore, and .rgignore, as well as applicable Git configuration. Its documented precedence is .rgignore over .ignore, and .ignore over Git ignore rules. It also skips hidden files and directories, binary files, and symbolic links unless you change those defaults. The official guide describes these filters and their options.
Widen the search selectively when you know a filter is responsible:
Rank #4
rg --hidden 'pattern'includes hidden paths.rg --no-ignore 'pattern'disables ignore-file filtering.rg --text 'pattern'treats binary files as text; control characters may make terminal output difficult to read.rg --follow 'pattern'follows symbolic links.rg -uuu 'pattern'disables ignore, hidden-file, and binary filtering.
The -u option can be repeated for progressively less filtering. If the search scope still seems unexpected, try rg --debug 'pattern' to inspect filtering and configuration behavior.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsChange what the output shows
By default, ripgrep prints matching lines with their file paths. These options make results easier to scan or process:
Best Value
rg -C 2 'panic'prints two lines of context before and after each match.rg -l 'TODO'lists matching file names rather than matching lines.rg -c 'TODO'reports the number of matching lines in each file.rg --fileslists files ripgrep would search without searching their contents.
The --replace option substitutes matched text in ripgrep’s displayed output; it does not edit files. The FAQ explains that ripgrep alone cannot search and replace files. If you combine match output with another editing tool to change files, review the intended targets before applying potentially destructive edits.
Quick Recap
Quickly choose the right command
- For an ordinary recursive search, start with
rg 'pattern'. - For literal text, use
-F; for case adjustments, use-ior-S. - For a smaller file scope, add a path,
-gglob, or-ttype. - If expected files are missing, check ignore rules, hidden paths, binary detection, and symbolic links before broadening the search.
- Use
rg --helpas the local reference: available options and support can vary by installed version.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




