Skip to content

Instantly share code, notes, and snippets.

@milnak
Last active March 21, 2025 16:12
Show Gist options
  • Save milnak/0e3e4abdfe3b28dd28c30bffe0cc5d7b to your computer and use it in GitHub Desktop.
Save milnak/0e3e4abdfe3b28dd28c30bffe0cc5d7b to your computer and use it in GitHub Desktop.
RipGrep (rg) Quick Reference

RipGrep (rg) Quick Reference

These are the most commonly used switches I use in rg.

Command Description
rg pattern Search pattern in current dir recursively
rg pattern utils.py Search in a single file utils.py
rg pattern src/ Search in dir src/ recursively
rg '^We' test.txt Regex searching support (lines starting with We)
rg -F '(test)' Search literally, i.e., without using regular expression
rg -i pattern Search pattern and ignore case (case-insensitive search)
rg -S pattern Smart case search (match case of pattern)
rg pattern -g '*.py' File globbing (search in certain files), can be used multiple times
rg pattern -g '!*.py' Negative file globing (do not search in certain files)
rg pattern -g '!dir1/' Exclude dir1
rg pattern -t py Search pattern in Python file. To list the supported filetypes, use rg --type-list
rg pattern -T py Do not search pattern in Python file type
rg -l pattern Only show file names containing pattern (Do not show the lines)
rg --files-without-match pattern Show files not containing pattern
rg -v pattern Inverse search (search lines not containing pattern)
rg -w pattern Search surrounded by word boundaries.
rg -A NUM Show NUM lines before each match.
rg -B NUM Show NUM lines before each match.
rg -C NUM Show NUM lines before and after each match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment