ripgrep (rg)

Updated

July 31, 2026

Overview

ripgrep (rg) is a line-oriented search tool that recursively searches your current directory for a regex pattern. It respects .gitignore rules by default and is designed to be significantly faster than standard grep.

Syntax

rg [options] PATTERN [PATH...]

Common Options

Option Description
-i, --ignore-case Search case-insensitively
-w, --word-regexp Match full words only
-t, --type TYPE Search only files matching file type (e.g., -t py, -t rust)
-T, --type-not TYPE Exclude files of a specific type
-g, --glob GLOB Include or exclude files/directories using glob patterns
-C, --context NUM Show NUM lines of contextual output before and after matches
-l, --files-with-matches Print only the names of matching files
-u, --unrestricted Don’t respect .gitignore (use -uu for hidden files, -uuu for binary files)

Key Use Cases

  1. Ultra-fast codebase searching in large projects.
  2. Filtering search results by language file types (-t).
  3. Searching while ignoring generated build outputs and git-ignored paths automatically.

Examples with Explanations

Example 2: Searching Specific File Types

rg -t python "import os"

Searches for import os strictly inside Python files (.py).

Example 3: Disregarding .gitignore and Hidden Files

rg -uu "SECRET_TOKEN"

Bypasses .gitignore filters (-u) and searches hidden dotfiles (-uu).

Understanding Output

Output is colorized by default when run in an interactive terminal. Each match section opens with the relative file path, followed by matching line numbers and highlighted line contents.