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?
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?
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 inevil-vars.el
. Its value is smartDocumentation:
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)
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.
Super old question, but for anyone looking for a more vim-like solution, try this:
(defun set-noic()
"set case sensitive"
(interactive)
(setq evil-ex-search-case 'sensitive))
(defun set-ic()
"set ignore case"
(interactive)
(setq evil-ex-search-case 'insensitive))
Then you can change case sensitivity using :set-ic
or :set-noic
, just like you did in vim. Just have to remember the dash.