2

I'm attempting to change the mapping of evil mode, and I have placed the code below in my .emacs file.

When I start emacs some of the keys have been remapped, while others have not

These keys got remapped correctly:

e down
n back
s insert
t append
z undo
Z redo
c copy line
v paste
l previous word

These keys did not:

u up
i forward
y next word

I have changed more than what's listed here, but these are what I tested.
The relevant additions to .emacs

(define-key evil-motion-state-map "e" 'evil-next-line)
(define-key evil-motion-state-map "n" 'evil-backward-char)
(define-key evil-normal-state-map "z" 'undo)
(define-key evil-normal-state-map "Z" 'redo)
(define-key evil-normal-state-map "c" 'evil-yank)
(define-key evil-normal-state-map "v" 'evil-paste-after)
(define-key evil-motion-state-map "l" 'evil-backward-word-begin)

(define-key evil-motion-state-map "u" 'evil-previous-line)
(define-key evil-motion-state-map "i" 'evil-forward-char)
(define-key evil-motion-state-map "y" 'evil-forward-word-end)
2
  • Could you please remove most of your keybindings from the post and only include the bindings you made for u, i, a, and y? It's hard to expect people to help if they have to wade through a mass of unrelated code.
    – Dan
    Jan 18, 2015 at 16:43
  • @Dan Okay, done.
    – Alice Ryhl
    Jan 18, 2015 at 16:51

1 Answer 1

2

The evil-normal-state-map has higher precedence than evil-motion-state-map, so since u already has a definition from evil (undo) which is located in evil-normal-state-map, the definition added in evil-motion-state-map dosen't take effect.

To fix this either remove the keymap of the key in evil-normal-state-map

(define-key evil-normal-state-map "u" nil)

Or clear all bindings in evil-normal-state-map

(setq evil-normal-state-map (make-sparse-keymap))

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.