1

When I enter C-x ESC I want the sequence to stop or cancel and I don't want Evil to wait for the next key or key chord in the sequence. Is there a way to achieve that?

1 Answer 1

1

Assuming you're in the GUI version of emacs, this is not too hard. The terminal is a different story.

Here is a function from my which-key package to help get you started. The idea is bind <escape> at every level of every keymap. There might be "simpler" but more error prone ways to do this, but it's not clear to me that they will be better. Try this to start. It will hit every key in the global-map.

(defun which-key-define-key-recursively (map key def &optional at-root)
  "Recursively bind KEY in MAP to DEF on every level of MAP except the first.
If AT-ROOT is non-nil the binding is also placed at the root of MAP."
  (when at-root (define-key map key def))
  (map-keymap
   (lambda (_ev df)
     (when (keymapp df)
       (which-key-define-key-recursively df key def t)))
   map))

(which-key-define-key-recursively global-map [escape] 'ignore)

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.