1

This question already has an answer here:

I tried to use a following

(global-set-key (kbd "C-[") nil)

but it also disables M-x. How can I properly disable it?

marked as duplicate by Constantine, Dan Oct 28 '15 at 18:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You can't: The Esc key is tied to 【Ctrl+[】 and Meta. Except if you have an azerty keyboard: (global-set-key (kbd "C-M-(") nil) – djangoliv Oct 28 '15 at 12:49
1

See this answer, which should solve your problem.


A second possibility is to selectively remap this key combination for Emacs but outside Emacs. The options available for this will depend on your operating system. On Windows, you could do this with AutoHotkey pretty easily. If you're on Linux, you might take a look at this answer.


(This is the previous content of my answer, moved here because it is less helpful than the above but may still be of interest.)

If you don't care about the Esc key per se, you may be able to sever the link between this pair of keys and Meta by setting meta-prefix-char, but a little bit of fiddling around has convinced me that this isn't as straightforward as simply setting the variable.

Specifically, I tried setting meta-prefix-char to nil. Following advice in @lawlist's comment on this question, I did so as early as possible in initialization to make sure all the keymaps got the hint, but some keybindings (most notably C-M-x in lisp-interaction-mode) were unexpectedly unbound, and I was getting many unexpected errors. It may be possible to sort all this out, but it's probably not worth the effort. Binding meta-prefix-char to an alternative key will probably work better, but your options are limited to single ASCII characters, none of which seem more appealing to me than C-[.

  • Ok, so not worth the effort. It is just too close to C-p so when I sometimes miss it I close all my frames. – Jānis Erdmanis Oct 28 '15 at 21:15

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