I used C-g to cancel operation in spacemacs, but feel ESC is a better way than C-g. I tried the following, but not work, spacemacs will report issue when startup:

(define-key key-translation-map (kbd "ESC") (kbd "C-g"))

is there any way to exchange this? thanks a lot


1 Answer 1


EDIT in response to question update

To exchange ESC (well 'escape') and C-g in both GUI and non-GUI Spacemacs you can use (NOTE that in non-GUI Spacemacs, the remapping of ESC to C-g does not work in the Spacemacs 'home screens', but I guess it does work in most other buffers. For example try pressing SPC followed by ESC in the home screen):

(define-key key-translation-map (kbd "<escape>") (kbd "C-g"))
(define-key key-translation-map (kbd "C-g") (kbd "<escape>"))


There is a difference between (kbd "ESC") and (kbd "<escape>"), as 'very' briefly explained in this answer.

The second line of what you tried works in non-GUI Spacemacs. The first line does not, as it is not possible to use "ESC" with a control key.

Finally, what you tried should work in GUI Spacemacs if you just replace the "ESC"s with "<escape>"s.

  • ok, I worked in no-gui mode, whatever, what is my question is how to exchange esc with C-g in spacemacs?
    – qbai
    Mar 23 at 2:45
  • I have updated the question in response to the update of the question (I've kept the old answer, please look again at its last line)... Mar 23 at 8:56

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.