9

I'm trying to perform a search and replace in spacemacs but I need it to be case sensitive when by default it appears to be case insensitive. So I try to do :set noignorecase but then I have this error message :

State noignore case cannot be set as initial evil state

Any idea how to perform a case sensitive search and replace with spacemacs?

Drew
  • 75,699
  • 9
  • 109
  • 225
ChiseledAbs
  • 449
  • 1
  • 4
  • 12

3 Answers3

8

Short and narrow answer

You need to set the variable case-fold-search to nil in order to have case sensitive search. So: put this somewhere in your init file:

(setq case-fold-search nil)

See the manual node on Searching and Case for more details.

Some background explanation

spacemacs relies heavily on evil, which emulates Vim. In general, you should not expect it to accept all (or even most) of Vim's syntax. :set noignorecase is straight out of Vim, but there is no set command in evil's limited set of ex commands.

The reason you got the error messages you did is (I think) because evil tries to match partially completed commands. In browsing through the list of ex commands evil emulates (hit C-h v evil-ex-commands to see the list), the only command that starts with set is:

("set-initial-state" . evil-ex-set-initial-state)

So, in effect, you tried to tell Emacs to set evil's initial state to noignorecase -- which doesn't exist, and is not at all what you intended to do.

Dan
  • 32,584
  • 6
  • 98
  • 168
1

Dan's answer was the solution in my case. Nevertheless, I also had to set the variable as default in my init.el in order to work:

(setq-default case-fold-search nil)
JoseleMG
  • 111
  • 1
0

If you just want to change to case-insensitive search for the current search session only, C-o in the search minibuffer to invoke the hydra interface, and C-c to toggle case sensitivity.

xuhdev
  • 1,839
  • 13
  • 26