This is a terminal restriction, because vi sees the keycodes as being the same. One can verify this by going into insert mode i, then hitting Ctrlv to put vi in a mode to expect the literal input of a special character and then hit e.g. CtrlShifta. A ^A
output will appear. Now do the sequence Ctrlv, Ctrla, and again a ^A
will appear: Both input sequences result in the same keycode being seen by vi.
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>[65;5u :echo "ctrl-shift-a received"<CR>
map <C-a> :echo "ctrl-a received"<CR>