Case-insensitive search in Vim

July 06, 2020

In Vim, if you want to find a word in a text, you run /something, then hit enter and move between the results with n / p (see :help search-commands).

By default it's case-sensitive, so if you have a text like this:

This is something. Something is good. sOmEtHing!

It will only find the first something (with lowercase s).

Case-sensitive search in Vim
Case-sensitive search in Vim

If you'd like to capture all occurrences no matter which case is used (case-insensitive search), you can append \c to your search pattern, like this:

/something\c

Case-insensitive search in Vim
Case-insensitive search in Vim

If you want this behavior by default, you can turn on the option:

set ignorecase

There's also a so-called "smartcase" (:help smartcase) which works as case-insensitive if you only use lowercase letters; otherwise, it will search in case-sensitive mode.

set smartcase
Vim For Developers

Vim For Developers

❄️ 35% off this Christmas season! ❄️

Learn Vim and upgrade your productivity to the next level by building the IDE of your dreams.

LEARN MORE