2

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.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
woodings
  • 7,503
  • 5
  • 34
  • 52

1 Answers1

2

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 ...

Community
  • 1
  • 1
François Févotte
  • 19,520
  • 4
  • 51
  • 74
  • Thanks! Actually I wanted to disable Esc prefix in my terminal, not only in Emacs. Is there a way to do this? – woodings May 31 '13 at 22:34
  • There might be iterm2-specific solutions to your problem, but I can't help you with this, since I'm no Mac user. I've taken the liberty to retag your question with `iterm2` in case specialists could help you. You might also have more success in asking the question on SuperUser (after rephrasing it on a more terminal-oriented way). – François Févotte May 31 '13 at 22:45