14

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).

  • 1
    Did you know there is a stackexchange sister site for vi/vim? – Philippos Apr 5 '17 at 12:20
  • 2
    \c is not a toggle, but actually forces case-insensitive matching. – muru Apr 5 '17 at 12:21
21

Use \C (uppercase) in your search pattern

See :help /ignorecase: "\C" does the opposite: Force matching case for the whole pattern.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.