ripgrep Manual
About
ripgrep (command: rg) is a line-oriented search tool that recursively searches your current directory for a regex pattern.
- It is much faster than
grep
- Basic usage:
rg <pattern>
- Matches lines with "foo" or "bar":
rg "foo|bar"
- Disables regex, searches literally:
rg -F "foo.bar"
- Only search in certain file types:
rg "import" --type py
- Exclude search from certain file types:
rg "main" --type-not cpp
- Search by file extension:
rg "main" -g "*.cpp"
ripgrep os usually 2x ~ 10x faster thant traditional grep:
- Respects
.gitignore, .ignore, .rgignore
- Skips hidden files and binary files by default.
- If you want to include everything:
rg --no-ignore --hidden <pattern>
- Useful options
-i (case-insensitive search)
-w (match whole words only)
-n (show line numbers, it is on by default)
-A 3 (show 3 lines after match)
-B 3 (show 3 lines before match)
-l (list only filenames with match)
-c (count matches per file)
-F (treat pattern as fixed string, not regex)
--no-ignore (dont respect .gitignore)
--hidden (include hidden files)
-g "pattern" (filter by glob pattern)
-t <lang> (limit to certain languages)