ripgrep Cheatsheet
ripgrep is a lightning-fast Rust-based text search tool that recursively searches directories. Automatically respects .gitignore and skips hidden files. 5-10x faster than traditional grep with PCRE2 regex support.
Updated: 2026-07-20·20 commands
Quick Start
``bash
rg 'function main' # Search recursively
rg -i 'class user' # Case-insensitive
rg -g '*.py' 'def' # Only Python files
rg -C 3 'error' # Show 3 lines context
rg -l 'TODO' # List filenames only
``
Startup & Modes(20)
| Command | Level | ||
|---|---|---|---|
rg --helpShow ripgrep help | Basic | rg --help | |
rg patternRecursively search current dir for pattern | Basic | rg 'function main' | |
rg -iCase-insensitive search | Basic | rg -i 'class user' | |
rg -wMatch whole word only | Basic | rg -w 'print' | |
rg -lOutput only matching filenames | Basic | rg -l 'TODO' | |
rg -cShow match count per file | Basic | rg -c 'error' | |
rg -nShow line numbers (default on) | Basic | rg -n 'import' | |
rg -gFilter files by glob pattern | Intermediate | rg -g '*.py' 'def' | |
rg -tFilter by file type | Intermediate | rg -t py 'class' | |
rg --type-listList all supported file types | Basic | rg --type-list | |
rg -AShow N lines after match | Basic | rg -A 3 'error' log.txt | |
rg -BShow N lines before match | Basic | rg -B 2 'error' log.txt | |
rg -CShow N lines around match | Basic | rg -C 3 'error' | |
rg -FFixed string mode (no regex) | Intermediate | rg -F 'hello.world' | |
rg -SSmart case (lowercase=insensitive, uppercase=sensitive) | Intermediate | rg -S 'Error' | |
rg --jsonJSON format output | Intermediate | rg --json 'pattern' | |
rg --no-ignoreSearch files ignored by gitignore | Intermediate | rg --no-ignore 'password' | |
rg --hiddenSearch hidden files | Intermediate | rg --hidden 'config' | |
rg -uuSearch all files (ignore .gitignore and hidden) | Expert | rg -uu 'secret' | |
rg -PUse PCRE2 regex (more powerful than default) | Expert | rg -P '(?<=$)\w+' |
FAQ
This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.