Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

πŸ€– Artificial Intelligence
☁️ Cloud and Infrastructure
πŸ’Ύ Data and Databases
πŸ’Ό Professional Skills
🎯 Programming and Development
πŸ”’ Security and Networking
πŸ“š Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
Β© 2026 CheatGridβ„’. All rights reserved.
Privacy PolicyTerms of UseAboutContact

ripgrep Code Search Cheat Sheet

ripgrep Code Search Cheat Sheet

Back to Operating Systems and CLI
Updated 2026-05-22
Next Topic: rsync File Synchronization and Backup Cheat Sheet

ripgrep (rg) is a line-oriented recursive search tool written in Rust that searches directories for regex patterns at exceptional speed. It was created to give developers a smarter default experience than traditional grep: it automatically respects .gitignore rules, skips hidden files and binary files, uses parallel multi-threaded search, and delivers full Unicode support without sacrificing speed. The key mental model is that ripgrep operates in two distinct modes β€” a blazing-fast default engine using finite automata (guaranteeing linear-time search) and an optional PCRE2 mode that enables look-around and backreferences at the cost of potentially slower, backtracking-based matching. Understanding this distinction explains nearly every performance characteristic and feature limitation you will encounter.

What This Cheat Sheet Covers

This topic spans 20 focused tables and 132 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Basic Pattern SearchTable 2: Case SensitivityTable 3: File Type FilteringTable 4: Glob Patterns β€” Include and ExcludeTable 5: Ignore File BehaviorTable 6: Output FormattingTable 7: JSON Output for Tooling IntegrationTable 8: Context LinesTable 9: Files-with-Matches, Files-without-Match, and Count ModesTable 10: Replace and Substitution (-r / --replace)Table 11: Multiline Regex (-U / --multiline)Table 12: PCRE2 Advanced Regex ModeTable 13: ripgrep Regex Syntax (Default Engine)Table 14: Sorting and ThreadingTable 15: Limiting and Scoping SearchesTable 16: Configuration FileTable 17: Advanced Features β€” Encoding, Compression, PreprocessorsTable 18: Performance OptimizationTable 19: Editor IntegrationTable 20: Comparison with grep, ag, and ack

Table 1: Basic Pattern Search

The foundation of ripgrep is a simple, ergonomic search invocation: provide a pattern and an optional path. By default, ripgrep recursively searches the current directory, treats the pattern as a regex, displays line numbers, groups results by filename, and highlights matches in color. These defaults are intentionally developer-friendly and differ meaningfully from POSIX grep.

CommandExampleDescription
Basic search
rg 'TODO'
Recursively searches the current directory for the pattern; shows file names, line numbers, and highlighted matches.
Search a specific file
rg 'TODO' src/main.rs
Searches only the specified file instead of the whole directory tree.
Search a directory
rg 'TODO' src/
Restricts recursive search to the given directory.
Search from stdin
cat file.log | rg 'ERROR'
ripgrep detects piped stdin automatically and searches it like a file.
Multiple patterns -e
rg -e 'TODO' -e 'FIXME'
Matches lines containing any of the specified patterns; each -e adds another alternation.
Patterns from file -f
rg -f patterns.txt src/
Reads one pattern per line from the file and searches for all of them simultaneously.

More in Operating Systems and CLI

  • ripgrep Code Search Cheat Sheet
  • rsync File Synchronization and Backup Cheat Sheet
  • AWS CLI Cheat Sheet
  • iptables Legacy Linux Firewall Reference Cheat Sheet
  • macOS Usage Cheat Sheet
  • tar gzip zip Archive and Compression Tools Cheat Sheet
View all 51 topics in Operating Systems and CLI