Prefer literal search when possible
Use fixed strings for maximum speed.
rg -F 'Content-Type:' .Literal search avoids regex overhead and is ideal for exact tokens.
Understand ripgrep defaults, debug missing results, and use PCRE2 or multiline search when required.
Keep searches fast while still finding what you need.
Use fixed strings for maximum speed.
rg -F 'Content-Type:' .Literal search avoids regex overhead and is ideal for exact tokens.
Search fewer files for faster results.
rg -t py 'dataclass' .Targeting the right file types can cut search time dramatically in large monorepos.
Limit results to inspect representative hits.
rg -m 1 'deprecated' src/When you only need confirmation, early cutoff saves time.
rg --one-file-system 'backup' /Useful in server environments with mounted volumes or network filesystems.
rg -j 4 'TODO' .ripgrep auto-detects threads well, but manual tuning can help in constrained environments.
Figure out why ripgrep did or did not return a match.
Show diagnostics about ignores, globs, and traversal.
rg --debug 'docker' .This reveals whether a path was skipped because of hidden-file, ignore, or glob rules.
Emit more verbose debugging than `--debug`.
rg --trace 'TODO' .Trace mode is noisier but can be useful when diagnosing regex, ignore, or performance issues.
Override binary skipping during diagnosis.
rg -a 'PNG' asset.binBinary detection can hide expected matches in mixed-content files.
rg '(?<=id=)\d+' file.txt && rg -P '(?<=id=)\d+' file.txtIf the default engine fails on look-around or backreferences, switch to PCRE2.
Run without ignore support to compare results.
rg --no-ignore 'generated' .A before/after comparison often immediately explains missing hits.
Handle patterns that span lines or depend on block structure.
rg -U 'first_name
last_name' sample.txtUse this for YAML, stack traces, templates, or prose blocks.
rg -Pzo '(?s)BEGIN.*?END' file.txt`(?s)` makes dot match newlines; `-z` turns NUL into the record separator for multi-line output.
Look for a key followed later by another key in the same block.
rg -U 'image: .*
(?:.*
){0,5}pullPolicy:' deploy.yamlMultiline search can quickly inspect structured config without a parser.
rg -U '"error"\s*:\s*true.*
.*"retry"' data.jsonFor more precision on JSON, consider `jq`, but multiline rg is good for exploration.
rg -Pzo '(?s)<script.*?</script>' index.htmlThis is useful for quick extraction or audits before using a proper parser.