By default, Vim/Vi’s search is case sensitive. However, if I want to search case insensitively, is there any method? For example, I search for
dog, instead of matching
dog only case sensitively, I also want to find out phases containing
There are several methods:
1. Setting the search to be case insensitive in Vim
Table of Contents
Set vim to
dog will match
To unset it:
You can also put it to your .vimrc if you want the behavior to be the default one.
C in search pattern
You can also force a pattern to be case insensitive or sensitive by adding
C regardless the setting of the settings of
For example, the search with
/dogc is always case insensitive. And
/dogC is always case sensitive.
The smartcase can only be used when the search pattern is typed and
ignorecase option is on.
To enable it:
:set ignorecase :set smartcase
If your search pattern is purely lowercase, it will search case insensitively.
If your search pattern contains uppercase characters, it will search case sensitively.