I recently noticed that in normal mode when I type Ctrl-i (command for jumps) it is "confused" for the TAB key. In particular, I have this mapping:
nnoremap <Tab> :tabnext<Enter>
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Most terminals, and most terminal emulators, send a ␉ (U+0009) character down the (virtual) wire to the host system when either ⇥ Tab or ⎈ Control+I are pressed. This is not
vim. This is how terminals work, and how the emulators that emulate them work too.
Similarly, and oft forgotten nowadays I observe, these terminals and terminal emulators send a ␛ (U+001B) character down the (virtual) wire to the host system when either ⎋ Esc or ⎈ Control+[ are pressed.
GUI applications can distinguish amongst specific key chords, because GUIs tend to operate in terms of key press and release messages. Terminal I/O applications just see the composed characters sent by the terminal, and cannot.
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to
<C-[> etc. (Only exception is
<C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim release.