Question

I'm a Vim user, and I decided to give Emacs a try.

Now I get a weird problem with Emacs. I installed the Evil mode, which is awesome.

In my .emacs I have the follow setting:

(define-key evil-motion-state-map "\C-u" 'scroll-up-command)

This works well.

But what if I wanted to change it to spacebar or Return key?

(define-key evil-motion-state-map "<return>" 'scroll-up-command)
(define-key evil-motion-state-map "SPC" 'scroll-up-command)

Nothing spectular will happen, the return/Enter key and spacebar are behaving their standard behaviour. I looked around for the right keys, and it seems they're the rights keys. For example,

(global-set-key (kbd "<return>") 'save-buffer) 

Works fine.

What am I doing wrong in Emacs/Evil with the Enter key?

Was it helpful?

Solution

  1. Use (kbd "<return>"), not "<return>". Likewise, (kbd "SPC").

  2. You probably want (kbd "RET"), not (kbd "<return>").

  3. Binding C-u, as you did at first, is a bad idea. You do not want to do that, ever. Just use C-u as it was intended, for command universal-argument -- see the Emacs manual, node Arguments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top