Thursday, June 18, 2009

vim: case insensitive search

vim/gvim has a default case sensitive search which is what I want most of the time.

There are times however when I need case insensitive searches. There are 2 ways to do this:

  1. First you can do

    :set ignorecase

    This sets the searches to ignore the case. Use :set noignorecase to revert to case sensitive search.

  2. The problem with that is if (like me) you only want to ignore case just for one search. It's a lot of keystrokes just to do this for one search. This takes care of that case. Use \c anywhere in the search pattern to ignore case. This does not touch the global setting of case.

Easy as pie. :)

Ad: Vim books

Ad: Regex books


Anonymous said...

Man I have been wondering about this lately. In userland case has no meaning. This is a big keystroke saver. Thanks!

It is a beautiful thing.

rr said...

You're welcome! :)

Anonymous said...

thanks for the tip! and i just discovered this works also the other way - \C (with capital C) results in case sensitive search, when ignorecase is enabled.

rr said...

You're welcome! And thanks for the tip too! will be putting that in an article.