Skip to main content

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)

CommandLevel
rg --help
Show ripgrep help
Basic
rg pattern
Recursively search current dir for pattern
Basic
rg -i
Case-insensitive search
Basic
rg -w
Match whole word only
Basic
rg -l
Output only matching filenames
Basic
rg -c
Show match count per file
Basic
rg -n
Show line numbers (default on)
Basic
rg -g
Filter files by glob pattern
Intermediate
rg -t
Filter by file type
Intermediate
rg --type-list
List all supported file types
Basic
rg -A
Show N lines after match
Basic
rg -B
Show N lines before match
Basic
rg -C
Show N lines around match
Basic
rg -F
Fixed string mode (no regex)
Intermediate
rg -S
Smart case (lowercase=insensitive, uppercase=sensitive)
Intermediate
rg --json
JSON format output
Intermediate
rg --no-ignore
Search files ignored by gitignore
Intermediate
rg --hidden
Search hidden files
Intermediate
rg -uu
Search all files (ignore .gitignore and hidden)
Expert
rg -P
Use PCRE2 regex (more powerful than default)
Expert

FAQ

This cheatsheet is compiled from official tool documentation. Last updated: 2026-07-20.