Skip to content

GrowlyX/instantgrep

Repository files navigation

instantgrep

Fast regex search using trigram indexes. Based on Cursor's research.

Builds a trigram inverted index over your codebase and uses it to skip files that can't possibly match — 14x–80x faster than grep/ripgrep on indexed repos.

Install

brew tap GrowlyX/instantgrep
brew install instantgrep

Or build from source:

mix deps.get && mix escript.build

Usage

Also available as igrep and instantgrep.

ig "pattern" path/                   # search (builds index on first run)
ig --build .                         # build/rebuild index
ig -i "todo|fixme" src/              # case-insensitive
instantgrep --no-index "pattern" .   # brute-force mode (no index)

Benchmark

./instantgrep-bench lib/
./instantgrep-bench --patterns patterns.txt --iterations 10 /path/to/project

How it works

Cursor's research

  1. Index — Extracts all overlapping 3-byte trigrams from every file, stores in an inverted index with bloom-filter masks
  2. Query — Decomposes your regex into required trigrams
  3. Filter — Looks up trigrams in the index to find candidate files
  4. Verify — Runs full regex only on candidates

License

MIT

About

CLI implementation of Cursor's Instant Grep in Elixir.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors