I've searched for this before but I've only seen questions like the below:

I don't have an understanding of what a major / minor mode really is (which both questions reference) (or whether it's relevant).

I'm trying to redefine the - key when I'm editing any file. It's currently defined by the evil-mode package in:


243:(define-key evil-motion-state-map "-" 'evil-previous-line-first-non-blank)

How would I go about redefining this to instead run a other function? What are my options - and their implications?

I've managed to what I assume redefines the keybinding by adding the following to my .spacemacs user-config:

  (define-key evil-motion-state-map "-" 'deer)

Which works, but it feels a bit hacky / cumbersome in case it ever conflicts with a future keybinding with another package.

  • The question is unclear, to me. You give an example (with deer) that you say works, and that looks like it would work (assuming there is a command deer). But you still have a question. What's the question, exactly? – Drew Dec 27 '18 at 3:04

You might want to take a look at the General.el, which, as far as I know, was designed to work coherently with evil. Here are the examples for evil bindings.

This is what might be relevant for you in terms of specifying both evil state and emacs major mode:

 :states ''motion
 :keymaps 'emacs-lisp-mode-map
 "-" 'deer)

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.