2
votes

I would like to be able to hit the space bar followed by another key as an alternative to hitting Ctrl and than the key in Normal State of Evil Mode.

For example, this is what I've started defining in my .emacs file:

(define-key evil-normal-state-map " ww" 'evil-window-next)
(define-key evil-normal-state-map " wr" 'evil-window-rotate-downwards)
(define-key evil-normal-state-map " wR" 'evil-window-rotate-upwards)
(define-key evil-normal-state-map " wo" 'delete-other-windows)
(define-key evil-normal-state-map " wn" 'evil-window-new)
(define-key evil-normal-state-map " wl" 'evil-window-right)
(define-key evil-normal-state-map " wh" 'evil-window-left)
(define-key evil-normal-state-map " wj" 'evil-window-down)
(define-key evil-normal-state-map " wk" 'evil-window-up)

From what I know so far, it seems as if I can only define a key sequence as a given function, and not as as something that wouldn't be used on its own such as Ctrl. Is there a general way of doing this so that the space bar followed by another key would be equivalent to any C-"that key" in Normal State of Evil Mode?

1

1 Answers

2
votes

I don't know enough about Evil to give you a specific answer, but you could try

(define-key function-key-map " " 'event-apply-control-modifier)
(define-key evil-normal-state-map " " nil)

Tho the function-key-map binding will only kick in if SPC is "unbound" in all other maps, so binding it to nil in evil-normal-state-map might not be sufficient. Otherwise you can use key-translation-map instead of function-key-map, so the rewrite will take precedence to the normal SPC bindings, but then you'll need to figure out how to enable/disable this binding when enering/leaving Evil's normal state.