1

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:

http://wikemacs.org/wiki/Evil#Enter_an_emacs_mode_in_a_given_state

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 '16 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 '16 at 6:17
  • @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. – Jordan Dashel Aug 8 '16 at 15:11
1

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. – Jordan Dashel Aug 10 '16 at 21:33
  • Didn't (evil-set-initial-state …) work along evil-default-state? I don't think you need hooks on this recipe – Felipe Lema Aug 11 '16 at 13:06
-1

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 '16 at 18:30
  • evil-local-mode? – wouter bolsterlee Aug 9 '16 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 '16 at 6:45

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.