0

I have remapped the evil-normal-state command bound to ESC in Evil Insert mode to C-o since the escape key is more difficult to reach on my keyboard than typing C-o. Now I want to use the original meaning of the ESC key as a prefix key instead.

I tried:

(define-key evil-insert-state-map (kbd "ESC") 'ESC-prefix)

but it does not work.

2

1 Answer 1

1

ESC is the escape character, <escape> is the symbol generated by pressing the ESC key in X. The escape character is generated when pressing something key together with the meta-key like M-x, that actually generates two key events, first the ESC event, second the x. (actually, that's only true in terminal mode since in X M-x generates a special event, but this event is mapped to ESC x). The problem is that in terminal mode the escape key does not generate <escape> but also ESC.

That said, in order to have the escape key working correctly in terminal, Evil has to catch the ESC event and possibly translate it to <escape> after some timeout (otherwise either bindings like M-x or leaving insert state with ESC would not work). In other words, the event ESC typically never reaches those keymaps because it is translated to <escape> before. The variable evil-intercept-esc can be used to customize this behavior (but only in newly created frames).

Your Answer

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

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