0

I have been trying to fix a terminal emulator behaviour in a situation where MacVim is running in iTerm2. I have the following key combinations assigned to individual actions in my Vim setup:

F10, action_A
CTRL-F10, action_B
SHIFT-F10, action_C

When I use those combinations in iTerm2 with Vim, SHIFT-F10 is interpreted correctly as action_A. However, the emulator is not able to distinguish between CTRL-F10 and F10 because of the esc sequence issue.

What I have noticed is that iTerm2 is configured to send Esc+[21;2~ whenever SHIFT-F10 is pressed. So by assigning the same sequence to CTRL-F10 I managed to force SHIFT-F10 and CTRL-F10 to perform action_C and F10 to perform action_A.

This proves that by sending the right esc sequence, one should be able to force iTerm2 to distinguish between different keys.

The question is: If SHIFT-F10 is associated with Esc+[21;2~ how do we find what CTRL-F10 is associated with? How do I find the esc sequence that represents CTRL-F10? or maybe the Hex Code? (as iTerm2 provides the option of sending a Hex Code to the terminal session)

mbilyanov
  • 2,315
  • 4
  • 29
  • 49
  • Its under Preferences -> Profile -> Keys, Add or change as nessesary – FDinoff Apr 08 '15 at 02:02
  • Hi @FDinoff, thanks for the help. I am trying to find the actual values (esc+) or hex that represents `CTRL-F10` so I can input those into that section: `Preferences -> Profile -> Keys` – mbilyanov Apr 08 '15 at 02:10

2 Answers2

1

In insert mode in vim, just hit Ctrl+V and press your keys. This will insert the escape literally along with the rest of the control code for this key combo. This is convenient when you're already editing a config file.

You can similarly run something like od -t x1 (for a hex dump) or even just cat, which doesn't interpret input, and just press your key combo there:

$ od -t x1
^[[21~
0000000 1b 5b 32 31 7e 0a
0000006

$

(press Ctrl-D once or twice to exit)

that other guy
  • 116,971
  • 11
  • 170
  • 194
  • the problem is, as we are trying to force iTerm2 to map a specific esc sequence to a key combination, we cannot really use a process that runs in iTerm2. When I hit `F10` and `CTRL-F10` they both will give me `^[[21~` I am trying to find the values for `CTRL-F10` and I cannot do that in a terminal. Is there a chart or an application that will give me the code for `CTRL-F10`. – mbilyanov Apr 08 '15 at 02:08
  • I don't follow. If you're remapping ctrl-f10, can't you choose an arbitrary sequence? Remapping ctrl-f10 in your terminal to whatever ctrl-f10 produces in your terminal sounds like a no op. – that other guy Apr 08 '15 at 16:18
  • Hi, my question has been answered here: https://groups.google.com/forum/#!topic/iterm2-discuss/4vzOE1W7Lmg If you have a mapping that goes as in vim, vim would expect that specific signal. – mbilyanov Apr 12 '15 at 19:55
0

Control-F10 could be sent as "\e[21;5~", using the action 'Send text with special chars'. Complete answer is here: how do I know what CTRL-F10 is associated with?

mbilyanov
  • 2,315
  • 4
  • 29
  • 49