3

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.

1
  • Could you please close the question if it worked?
    – clemera
    Dec 9, 2015 at 12:21

1 Answer 1

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.

1
  • Super. Gonna try that. Nov 23, 2015 at 16:24

Your Answer

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

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