32

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

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

1 Answer 1

44

Use \C (uppercase) in your search pattern

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

1
  • e.g. to search for WORD, type /WORD\C
    – 林果皞
    Apr 12 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .