What ripgrep Does
- Recursive search — walks directory tree
- Gitignore aware — skips .gitignore, .ignore, global ignore
- Smart case —
--smart-casefor case-insensitive when all lower - File types —
--type jsor--type-addcustom - Globs —
-ginclude/exclude patterns - Regex — full Rust regex engine (PCRE2 with
-P) - Context —
-A/-B/-Clines around matches - Output — text, JSON, vimgrep, colored
- Parallelism — multi-threaded by default
Architecture
Single Rust binary. Uses memchr + SIMD for byte-level search, regex crate for patterns. Walks filesystem in parallel (one thread per CPU). Respects .gitignore via the ignore crate.
Self-Hosting
CLI tool, self-contained binary.
Key Features
- Fastest grep alternative (sometimes 10x faster than grep)
- Gitignore/ignore respect
- Parallel search
- JSON output mode
- File type filters
- Unicode aware
- PCRE2 support (with
-P) - Replace mode (
-r) - Integrates with VS Code, Helix, Zed, IntelliJ
Comparison
| Tool | Language | Gitignore | Speed | Regex |
|---|---|---|---|---|
| ripgrep (rg) | Rust | Yes | Fastest | Rust regex + PCRE2 |
| The Silver Searcher (ag) | C | Yes | Fast | PCRE |
| ack | Perl | No (manual) | Slow | Perl regex |
| grep | C | No | OK | POSIX/PCRE |
| git grep | C | Git-aware | Fast | Git regex |
常见问题 FAQ
Q: 和 grep 比快多少? A: 一般 2-10 倍。大仓库(Linux kernel 级)差距更大,因为 ripgrep 并行且跳过 .gitignore。
Q: 能搜隐藏文件?
A: 默认跳过。加 -. 或 --hidden 启用。
Q: 为什么是公共领域许可? A: 作者 BurntSushi 的选择。Unlicense 等同于放弃版权,完全自由使用。
来源与致谢 Sources
- GitHub: https://github.com/BurntSushi/ripgrep
- License: Unlicense/MIT