When I'm in Emacs
with iTerm2
, pressing Esc and b after in a short time sends Meta+b which runs backward-word
. How can I make them separate keys?
I want to make the change in iterm2
- independent of Emacs
.
When I'm in Emacs
with iTerm2
, pressing Esc and b after in a short time sends Meta+b which runs backward-word
. How can I make them separate keys?
I want to make the change in iterm2
- independent of Emacs
.
You can do something like the following:
(global-set-key (kbd "<escape> b") 'your-function)
Hewever, please note that by doing this, you lose the ability to replace the M- modifier by the ESC prefix for all other key bindings, not just M-b.
To limit this potentially unwanted side-effect, you could use the technique presented in this answer, to be able to easily switch between your custom behaviour and the standard one.
Nb: When using Emacs in no-window mode, please note that this will only work if your terminal sends different inputs for ESCb and M-b. Otherwise, there is no way Emacs can tell the difference.
You can check this typing C-hkESCb. If Emacs is receiving a specific input, you will see something like:
M-b (translated from <escape> b) runs ...