Ripgrep: How to Search Case Insensitive

Updated

Learn how to run a case-insensitive search with ripgrep (rg)

Ripgrep: How to Search Case Insensitive

Before we start, make sure you have ripgrep installed on your computer. On a Mac, you can install it with Homebrew:

brew install ripgrep

By default, ripgrep is case-sensitive, so searching for storage won't find localStorage. To ignore case, open your terminal, go to your project folder and run:

rg -i "pattern"

The -i flag is short for --ignore-case, so capitals and lowercase count as the same letter. In my demo, that took the search from 3 matches to 7.

There's also smart case, with a capital -S:

rg -S "pattern"

With -S, an all-lowercase pattern ignores case, but as soon as your pattern contains a capital letter, the search becomes case-sensitive again. Just be careful with a lowercase -s: it does the opposite and forces a case-sensitive search.

undefined

To make smart case your default, add --smart-case to a ~/.ripgreprc file and point the RIPGREP_CONFIG_PATH environment variable at it in your ~/.zshrc.