ripgrep
Back to Terminal
ripgrepBeginner7 min

ripgrep (rg) Tutorial: Fast Codebase Search with Regex Patterns and File Filters

ripgrep vs grep — Why Speed Matters

ripgrep (rg) is significantly faster than grep and respects .gitignore by default. Learn the regex patterns, file type filters, and flags that make it indispensable for codebase search.

ripgrep (rg) is the fastest text search tool available — it respects .gitignore by default and uses SIMD for blistering speed on large codebases.

By the end of this 7 min guide, you'll have a working ripgrep setup and practical ripgrep workflows you can use immediately.

Installation & Basic Usage

Install ripgrep:

brew install ripgrep
Tip: Verify the installation with ripgrep --version or ripgrep -V after installing.

Regex Pattern Syntax

ripgrep's power comes from file type filters and regex. Use --type to search specific languages and -g to include/exclude patterns.

Here's a foundational configuration to start with:

# Common ripgrep usage
rg "pattern" --type py
rg "TODO" -g "!node_modules"
rg "function" -l  # list files only
rg "pattern" --json  # structured output

File Type Filters & Globs

With ripgrep configured, these ripgrep-specific workflows will save you time every day:

Pro tip: Don't try to adopt everything at once. Start with rg "pattern" basic search and add more as it becomes habit.

Search, Replace & Output Formats

Once you're comfortable with ripgrep basics, these advanced techniques will transform your ripgrep workflow:

Search Performance on Huge Repos

Here are the most common ripgrep issues and how to fix them:

Search Mastery

Congratulations — you now have a solid ripgrep foundation. Here's where to go next:

← PreviousRaycast Extension Development Tutorial: Build and Publish with TypeScript and ReactNext →Obsidian Dataview Query Examples: 25 Practical Recipes for Your Vault