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.

Håkon Hægland
  • 3,648
  • 1
  • 22
  • 51

1 Answers1

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).

fifr
  • 91
  • 1