I want Emacs to default to Emacs bindings, but to be able to define a list of modes in init.el that enable evil-mode.

I want something similar to this:


but in reverse, where evil is explicitly enabled by mode, rather than Emacs bindings being enabled by mode.

  • Have a look at the Emacswiki and scroll down to "Modes' initial state".
    – Dan
    Aug 4, 2016 at 18:38
  • Why? Evil is specially built to be enabled globally, therefore it allows bypassing its keys by using Emacs state.
    – wasamasa
    Aug 5, 2016 at 6:17
  • 1
    @wasamasa I only like using vim bindings for code editing and a handful of other tasks. I have a snippet in my init.el that disables evil for a number of modes like org-mode, info-mode, diary-mode, dired-mode etc. It's gotten unruly because there are so many modes that I prefer to have the original bindings for. Aug 8, 2016 at 15:11

2 Answers 2


You can customize-variable evil-default-state (to emacs, insert ...)

  • This is close to what I want. How would I go about enabling vim bindings for specific modes, like prog-mode? I unsuccessfully tried adding a hook, but my elisp abilities are elementary. Aug 10, 2016 at 21:33
  • Didn't (evil-set-initial-state …) work along evil-default-state? I don't think you need hooks on this recipe Aug 11, 2016 at 13:06

aren't you looking for normal major mode hooks, such as this one:

(add-hook 'python-mode-hook 'evil-mode)

...to enable evil mode only when editing python files?

note that you can also use prog-mode-hook which is intended to be a catch-all hook for any programming language major mode.

  • evil-mode is global, so your suggestion will not work. Neither will using the hook system to enable specific states, as evil is initialized after them.
    – wasamasa
    Aug 9, 2016 at 18:30
  • evil-local-mode? Aug 9, 2016 at 21:50
  • That can be used, but will lead to bugs as Evil has been designed to be used as a global minor mode. Your best bet is to just customize the initial states, really.
    – wasamasa
    Aug 10, 2016 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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