4

Unlike isearch, evil-search mode ignores case-fold-search option.

Using evil-search like this for eg:

(setq-default evil-search-module 'evil-search)

Is it possible to make evil-search case sensitive?

  • Looking at evil-search source, it looks like it follows search-upper-case instead – Felipe Lema Mar 10 '17 at 12:40
6

What to do

You can customize the variable evil-ex-search-case to tell it what you want evil to do when searching. Here's the docstring:

evil-ex-search-case is a variable defined in evil-vars.el. Its value is smart

Documentation:

The case behaviour of the search command. Smart case means that the pattern is case sensitive if and only if it contains an upper case letter, otherwise it is case insensitive.

You can customize this variable.

If you dig into the source code, this is the variable in question:

(defcustom evil-ex-search-case 'smart
  "The case behaviour of the search command.
Smart case means that the pattern is case sensitive if and only
if it contains an upper case letter, otherwise it is case
insensitive."
  :type '(radio (const :tag "Case sensitive." sensitive)
                (const :tag "Case insensitive." insensitive)
                (const :tag "Smart case." smart))
  :group 'evil)

Now: you can either use the customize interface to choose your option, or you could put the following in your init file:

(setq evil-ex-search-case 'sensitive)

Here's how I found this information.

First, I asked apropos to tell me about various functions and variables related to evil searches (M-x apropos evil search). I then searched that list for mentions of "case," and checked out the variable evil-ex-search-case. When that looked like the relevant variable, I followed the link in the help window to the source code to figure out what value I needed to set it to.

  • Thanks for the comprehensive answer, I'd actually read over the source code for evil-search but found multiple terms that mention case (evil-ex-regex-case. evil-ex-regex-without-case, evil-ex-pattern-ignore-case)... so wasn't sure which was important to access. – ideasman42 Mar 11 '17 at 6:25

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.