Use case sensitive search for lower-case string using smartcase
8,922
Use \C
(uppercase) in your search pattern
See :help /ignorecase
: "\C" does the opposite: Force matching case for the whole pattern.
Related videos on Youtube
Author by
user2891462
Updated on September 18, 2022Comments
-
user2891462 over 1 year
I normally enable
smartcase
in my.vimrc
.Without
smartcase
:- If I want case-insensitive search, I write in upper-case or lower-case (doesn't matter) and append a
\c
at the end of the query. - Case-sensitive search happens by default.
With
smartcase
:- If I want case insensitive search, I write all in lower-case.
- If I want case sensitive search, I write the upper-case letters in upper-case.
But, with
smartcase
enabled, how can I say that I want a case sensitive search of a lower-case pattern? I was expecting that appending a\c
would revert the type of search (so that if I had written all in lower-case, i.e. case-insensitive search, it would turn to a case-sensitive search; and if I had written some upper-case letters, i.e. case-sensitive search, it would turn to a case-insensitive search), but that does not seem to be the case (no pun intended).-
Philippos about 7 yearsDid you know there is a stackexchange sister site for vi/vim?
-
muru about 7 years
\c
is not a toggle, but actually forces case-insensitive matching.
- If I want case-insensitive search, I write in upper-case or lower-case (doesn't matter) and append a