Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I send Ctrl+; in iterm2 (emacs)?

There seems to be a solution here, here and here

These are close to what I want, but I am still unable to make it work.

share|improve this question
    
Adapting my answer to the third link and sending 0x1B 0x3B doesn't work? – Daniel Beck Mar 20 '14 at 18:54
    
Thanks for the response. I tried it, and realized 0x1B = ESC not control? (emacs sees it as M-; not C-;) – eugene Mar 21 '14 at 1:14
up vote 0 down vote accepted

The way I make these key combinations work is to go to the Keys section of the iTerm prefs and create a shortcut for ^; that sends some escape sequence, like ^[[aa (you can replace aa with anything, but be aware that some things are mapped to actual keys). Then in your .emacs, create a keyboard shortcut for what you want it to map to, like

(global-set-key (kbd "C-[ [ a a") 'the-function-you-want-to-map-to)
share|improve this answer

How to bind a key sequence to the control key in Iterm2

  1. Download the free application “Key Codes" from the app store. Install it from the link below and then open it.

  2. Hit the Ctrl+some key in this case I’ll use Ctrl+w.

    How to get the hex code

  3. The code in the red square is the code we want to send to the terminal

  4. Now map your key sequence using in iterm, preferences->Keys->+.

    How to map the command to the hex code

  5. This will now map opt+←delete to Ctrl+w in the terminal, but you can use it to map any key to another one. I know Ctrl+w is a bad example for Emacs since it doesn't support Ctrl+w but you can use this methodology for Emacs compatible shortcuts.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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