5

I'm currently trying to learn org-mode in OS X. And I found there's a keymap M-S-RET. But S-RET is not recognized in the iTerm2.

  • It seems like terminal interpret S-RET and RET as same.
  • iTerm2 can bind a S-RET in the GUI preference tab. (PREFERENCE->PROFILE->KEY)
  • I can bind S-RET and send hex value instead of 13. (13 is keycode for RET) enter image description here

But I can't find what's the keycode for the S-RET. Actually, I think Shift + Enter does not exist as keycode. However, there must be some key combination that Emacs uses.

How can I figure it out? Are there any files containing that information?

Thank you for reading.

1
3

C-c C-x M is an alternative for M-S-Ret

http://orgmode.org/manual/TTY-keys.html#TTY-keys

1

There isn't really a standard escape sequence for Shift+Return. You could say that there are two standards, but each of them is only followed by a small number of terminals:

  • libtermkey: "\e[13;2u"
  • xterm: "\e[27;2;13~"

But Emacs only activates them if it can figure out that the current terminal sends them. Since iTerm2 doesn't send them by default, Emacs doesn't activate them.

You might as well use one of these sequences. To activate them unconditionally, put the following code in your init file (this code is from terminal-init-xterm in term/xterm.el):

(load "term/xterm")
(let ((map (copy-keymap xterm-function-map)))
  (set-keymap-parent map (keymap-parent input-decode-map))
  (set-keymap-parent input-decode-map map)))

For more information and some explanation of these escape sequences, see Problems with keybindings when using terminal

1

As Eric notes above, there is an alternative key binding for M-S-Ret:

C-c C-x M is an alternative for M-S-Ret

(More precisely, both are bound to (org-insert-todo-heading) in org-mode.)

You can set iTerm2 to send the hex codes corresponding to the alternative key sequence when you press M-S-Ret, thereby invoking the same function and behavior.

The required hex codes:

  • C-c is 0x03
  • C-x is 0x18
  • M is 0x4D

Assuming that you are using the Option key as the Meta key on your Mac keyboard, go to iTerm2 Preferences > Profiles > Keys and map Option-Shift-Return to send these codes.

enter image description here

Now, when you press Option-Shift-Return (i.e., M-S-Ret), iTerm2 sends C-x C-x M.

Et voilà.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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