Ubuntu – Gnome-terminal + Vim and Ctrl-Shift mappings

gnome-terminalvim

Is it possible to map sequence with CtrlShift in Gnome Terminal?

I'm trying to add the mappings

  • map <C-S-[> gT
  • map <C-S-]> gt

and it's not working. How to do that?

Somehow I mapped <C-S-]>, but it turned out it's not <C-S-]>, but <C-]>, so it looks like it doesn't recognize Shift in this sequence. It's misconfigured or it's gnome-terminal's fault?

Besides. Mapping <C-[>, after pressed, looks like vim is waiting. I suppose it's mapping timeout, but how to get rid of this timeout when I press precisely <C-[> and I don't want to press anything else?

I just started learning vim, so sorry if there is something obviously wrong in that mappings.

Best Answer

I think the problem here is that you are trying to get vim, which expects to run in a terminal, to recognize a CTRL-SHIFT sequence. While it's possible for X to recognize such combinations, applications that run in a terminal (or, these days, a terminal emulator) cannot. This is because, historically, terminals could only send and receive seven- or eight-bit sequences of ASCII data across a serial connection (though this could include "escape sequences" that position the cursor, scroll or delete lines, change color and other helpful effects).

There are 32 "Control Codes" in the ASCII character set, including the familiar CTRL-A through CTRL-Z. But there are no corresponding ASCII codes for "CTRL-SHIFT" A through Z. Now, gnome-terminal itself can recognize these codes (CTRL-SHIFT-V, for instance, will paste text from the clipboard), but vim will not be able to have direct access to it.

Of course, it may be possible (I don't know) for a terminal emulator to be set up to convert CTRL-SHIFT key presses to an escape sequence which can then be recognized by a vim mapping.

=======

UPDATE

You might be interested in gvim, which is a graphical version of vim that runs as an X program rather than a terminal program. Maybe gvim will be able to understand CTRL-SHIFT codes?