Complete Feature Guide
Everything ripgrep can do — from smart defaults to advanced PCRE2 regex, compressed file search, and deep editor integration.
Core Search Capabilities
Flexible pattern matching for any search task.
- ✓ Regex pattern matching (Rust regex engine by default)
- ✓ Literal fixed-string search (
-F/--fixed-strings) - ✓ Case-insensitive search (
-i) - ✓ Word boundary matching (
-w) - ✓ Multi-pattern search (
-e pattern1 -e pattern2) - ✓ Inverted matching — show lines that do NOT match (
-v)
# Regex search
rg 'fn \w+\(' src/
# Literal string (no regex interpretation)
rg -F 'user.name[0]' .
# Case-insensitive
rg -i 'error'
# Word boundary
rg -w 'main'
# Multiple patterns
rg -e 'TODO' -e 'FIXME' -e 'HACK'
# Inverted — lines without "test"
rg -v 'test' Performance
Built in Rust with every optimization that matters.
- ✓ Parallel directory traversal using all CPU cores
- ✓ Memory-mapped I/O for large files
- ✓ SIMD-accelerated literal searching
- ✓ Lazy line-by-line reading — never loads full file into memory
- ✓ Intelligent skipping of binary and very large files
- ✓ Efficient UTF-8 validation built into the search
# Search the entire Linux kernel (25M+ lines) in under 100ms
rg 'EXPORT_SYMBOL' ~/linux/
# Show timing with -Stats flag
rg --stats 'TODO' . Smart Filtering
Automatically ignores files you do not want to search.
- ✓ Respects
.gitignore,.ignore, and.rgignorefiles - ✓ Skips hidden files and directories by default
- ✓ Detects and skips binary files automatically
- ✓ Global ignore file support (
--ignore-file) - ✓ Override any filter with
--no-ignore,-u,-uu - ✓ Custom glob patterns (
--glob "*.ts",--glob "!node_modules")
# Use your gitignore rules (default behavior)
rg 'pattern'
# Include hidden files too
rg -. 'pattern'
# Search everything — ignore all ignore files
rg -uu 'pattern'
# Restrict to TypeScript files via glob
rg --glob '*.ts' 'interface'
# Exclude a directory
rg --glob '!dist/**' 'TODO' File Type Filtering
Search by language or file type with a single flag.
- ✓
-t / --typeto include only a specific type - ✓
-T / --type-notto exclude a type - ✓
--type-listto see all 200+ built-in types - ✓ Define custom types with
--type-add - ✓ Types are glob-based and composable
# Only Python files
rg 'def ' -t py
# Only Rust files
rg 'fn main' -t rust
# Exclude test files
rg 'TODO' -T test
# List all built-in types
rg --type-list
# Define a custom type and use it
rg --type-add 'web:*.{html,css,js}' -t web 'class=' Advanced Regex (PCRE2)
Switch to the full PCRE2 engine when you need look-arounds or backreferences.
- ✓ Default: Rust
regexengine — fast, Unicode-aware, no backtracking catastrophe - ✓ PCRE2 mode (
-P) unlocks look-ahead, look-behind, and backreferences - ✓ Automatic engine selection with
--auto-hybrid-regex - ✓ Full Unicode character class support (
\p{Letter},\p{Han}) - ✓ Named capture groups (
(?P)...)
# Look-behind (requires PCRE2)
rg -P '(?<=fn )\w+'
# Backreference
rg -P '(\w+) \1'
# Unicode: find Chinese characters
rg '\p{Han}+'
# Named capture group
rg -P '(?P<year>\d{4})-(?P<month>\d{2})' Output Formatting
Control exactly how results are displayed.
- ✓ Colored output by default (file, line number, match highlighted)
- ✓ Context lines — before (
-B), after (-A), or both (-C) - ✓ Show only file names (
-l) or count of matches (-c) - ✓ JSON output (
--json) for piping to other tools - ✓ Statistics mode (
--stats) — total matches, files searched, elapsed time - ✓ Quiet mode (
-q) — exit code only, no output
# 3 lines of context around each match
rg 'error' -C 3
# Only list file names with matches
rg -l 'TODO'
# Count matches per file
rg -c 'import'
# JSON output for scripting
rg --json 'pattern' | jq '.data.lines.text'
# Print stats summary
rg --stats 'fn ' src/ File Encoding Support
Search files in any encoding, not just UTF-8.
- ✓ UTF-8 by default with strict validation
- ✓ UTF-16 auto-detection via BOM
- ✓ Explicit encoding override with
-E/--encoding - ✓ Supports Latin-1, GBK, EUC-JP, Shift-JIS, and more
- ✓
--text(-a) to treat binary as text (useful for Latin-1 logs)
# Force Latin-1 encoding
rg -E latin-1 'pattern' legacy-file.txt
# Search a UTF-16 file (auto-detected if BOM present)
rg 'pattern' windows-file.txt
# Treat all files as text (including binary)
rg -a 'pattern' Compressed File Search
Search inside archives without extracting them first.
- ✓ Enable with
-z/--search-zip - ✓ Supports: gzip (
.gz), bzip2 (.bz2), xz (.xz), LZ4, Brotli, Zstandard, LZMA - ✓ Automatically decompresses on the fly
- ✓ Works with file type filtering
# Search inside .gz log files
rg -z 'ERROR' /var/log/app.log.gz
# Search all compressed files in a directory
rg -z 'pattern' /var/log/ Search & Replace
Preview or apply replacements with capture group support.
- ✓
-r/--replaceto substitute matches in output - ✓ Capture group references (
$1,$name) - ✓ Preview replacements before writing (pipe to file or use
sd) - ✓ Works with all filtering options
# Show what a replacement would look like
rg 'fn (\w+)\(' -r 'function $1(' src/
# Combine with capture groups
rg '(\d{4})-(\d{2})-(\d{2})' -r '$3/$2/$1' dates.txt
# Write replacement output to a new file
rg 'old_api' -r 'new_api' main.go > main_updated.go Integration & Scripting
ripgrep is designed to work with other tools and editors.
- ✓ JSON output (
--json) for structured consumption by scripts - ✓ Non-zero exit code when no matches found — scriptable in
ifstatements - ✓ Shell completions for bash, zsh, fish, Elvish, and PowerShell
- ✓ Configuration file (
.ripgreprcorRIPGREP_CONFIG_PATH) - ✓ Used internally by VS Code, Neovim (telescope.nvim), Helix, and many more
- ✓ Preprocessing support — pipe through any command before searching
# Use in a shell if statement
if rg -q 'TODO' src/; then
echo "Found TODOs!"
fi
# Generate shell completions
rg --generate complete-bash >> ~/.bashrc
# Set permanent flags via config file
echo '--smart-case' >> ~/.ripgreprc
echo '--hidden' >> ~/.ripgreprc
# Preprocess PDFs before searching
rg --pre pdftotext 'keyword' docs/ Ready to get started?
Download ripgrep and try these features yourself — it takes under a minute to install.