rg -B 2 'panic!' src/Useful for reading the setup or declaration that leads into a match.
Control headings, context lines, counts, paths, columns, and machine-readable output.
Print surrounding lines to understand matches without opening an editor.
rg -B 2 'panic!' src/Useful for reading the setup or declaration that leads into a match.
rg -A 3 'TODO' .Often used to inspect comments, config blocks, or stack traces.
rg -C 2 'Exception' app.logContext mode is a fast middle ground between plain search and opening the file.
Make grouped output easier to parse visually.
rg -C 1 --context-separator '---' 'timeout' log.txtEspecially helpful in scripts or when pasting results into notes.
Stream a file through rg without dropping non-matching lines.
rg --passthru -n 'ERROR|WARN' app.logGood for presentations, log review, or quick visual filtering.
Tune filenames, headings, columns, and path formatting for humans or tools.
Print file names inline per match instead of grouped headings.
rg --no-heading -n 'TODO' .Many editors and scripts prefer one match per line with filename and line number.
rg --with-filename -n 'host' nginx.confUseful in scripts or when concatenating outputs from multiple commands.
rg --column 'SELECT' migrations/Editor integrations often use filename, line, and column to jump to a result.
Return the matched substring instead of the full line.
rg -o '\b[A-F0-9]{8}\b' dump.txtGreat for extracting tokens, IDs, codes, or other bounded fragments.
Show how a replacement would look without editing files.
rg -N --replace '$1_id' '([a-z]+)Id' src/ripgrep does not rewrite files, but `--replace` is excellent for previewing transformations.
Get summaries and structured output for automation and analysis.
Show counts and timing information at the end of a search.
rg --stats 'use client' app/Useful when comparing search breadth or measuring refactor scope.
rg -q 'TODO' .This is useful in shell scripts and CI checks.
rg --json 'password' .Structured output is safer than parsing human-readable text.
Choose a custom separator for path rendering.
rg --path-separator '/' 'TODO' .Helpful when running on Windows but generating cross-platform output.
rg -m 3 'deprecated' src/Speeds up scans when you only need sample hits, not exhaustive results.