Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Is it possible to map sequence with CTRL-Shift in gnome-terminal?

I'm trying to add 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.

share|improve this question

5 Answers 5

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.



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?

share|improve this answer

seems to be an issue with the gnome terminal, not allowing certain combinations with the ctrl-key. google shows a lot of this.

just in case you don't konw it, ctrl-page up/down cycles through tabs.

share|improve this answer

As Bartleby pointed out this is a terminal restriction, because vi sees the keycodes as being the same.

For terminals such as xterm you can change that. For gnome-terminal which ignores the X resources settings I don't know how to do the following:

This SO question covers the same topic, and this example shows this in use for mapping multiple keys in the .Xresources file. E.g.:

XTerm*vt100.translations: #override \
  Ctrl ~Meta Shift <Key>a: string(0x1b) string("[65;5u") \n\
  Ctrl ~Meta Shift <Key>b: string(0x1b) string("[66;5u") \n\ 
  Ctrl ~Meta Shift <Key>f: string(0x1b) string("[70;5u")  

Now we have different key sequences coming into vi for Ctrla vs. CtrlShifta, Ctrlb vs. CtrlShiftb, Ctrlf vs. CtrlShiftf.

We can now map them differently in ~/.vimrc:

map <ESC>[66;5u   :echo "ctrl-shift-b received"<CR>
map <ESC>[70;5u   :echo "ctrl-shift-f received"<CR>
map <C-b>         :echo "ctrl-b received"<CR>
map <C-f>         :echo "ctrl-f received"<CR>
share|improve this answer
The original question was about gnome-terminal, whereas your response refers to xterm. – egmont Sep 22 at 19:33
@egmont: Good point, and an oversight on my side. According to this answer the .Xresources are ignored by gnome-terminal. That is unfortunate. Updated answer. – cfi Sep 23 at 5:55
Slightly reworded/crossposted this answer as a Q&A pair to SuperUser, because I should probably delete it here because it does not apply to the asker's terminal. – cfi Sep 23 at 6:22

It seems you just have to disable all keyboard shortcuts in gnome-terminal.

share|improve this answer
Why does disabling keyboard shortcuts help? – Eliah Kagan Jan 24 '13 at 1:45
It does not seem to help at all, from my experience. – Elliot Foster Mar 25 '14 at 21:37

In gnome-terminal the escape sequences generated by keys are not configurable. For many keys Ctrl+key and Shift+Ctrl+key generate different sequences; unfortunately for [ and ] they don't, so you can't distinguish them.

share|improve this answer

Your Answer


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.