0

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

qbai
  • 13
  • 3

1 Answers1

0

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

END EDIT

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.

dalanicolai
  • 6,108
  • 7
  • 23
  • 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 '23 at 02: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)... – dalanicolai Mar 23 '23 at 08:56