2

I would like to assign evil-mode normal-state key bindings dependent on what major mode I am currently working in.

E.g. I am using org-mode and I want a set of keys and if I use AucTeX I want a different set of keys. Potentially there are keys that behave differently under different major modes because I want to keep a certain naming logic.

I tried assigning keys using different minor-modes, however the last loaded minor-mode overwrites the previously assigned key bindings. Switching to a different window with a different major mode does not switch the key bindings back.

  • Could you please close the question if it worked? – clemera Dec 9 '15 at 12:21
4

You can use evil-define-key.

For example to bind "a" in normal-state to different commands in org-mode and emacs-lisp-mode, you would do:

(evil-define-key 'normal org-mode-map "a" 'bar) 
(evil-define-key 'normal emacs-lisp-mode-map "a" 'foo) 

Now "a" in normal state is bound to command bar in org-mode and command foo in emacs-lisp-mode.

  • Super. Gonna try that. – cataclysmic Nov 23 '15 at 16:24

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.