Your comment indicates that this problem exists only with certain terminal emulators like gnome-terminal
No I'm on Linux Mint. Just installed terminator and there it works. Seems to be some issue with Gnome Terminal
Gnome-terminal is known to have trouble with mapping modifier keys in vim
Example: The problem is that in a terminal, a Tab character is ^I (Control-I). This means that pressing control while pressing tab is not something the terminal even bothers to pass through to Vim. It just sends a regular tab character.
GVim can support this because it doesn't have to rely on the terminal to tell it what keys are being pressed in what combination--it has more direct access to keyboard events, so it has no trouble seeing modified special keys.
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 some workarounds for it:
First, we need to know what command your terminal sends when a certain key combination is pressed:
To do so press
Control + Shift + v
Now press the key combination
Ex: I am running headless server and for me
Enter shows the same output
^[ This means that shift+enter and control+enter and enter are taken similarly by the terminal.
shift+enter combination would also affect
- Record your output
enter gives me
- man ascii
Look in the manpages of ascii and you will see that
\r is for
so now mapping
<CR> will map enter keys
Following these methods you might be able to find the specific
Even though it should solve the problem, YMMV
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals..
Vim's keyboard input system revolves centrally around a queue of bytes.
This worked well when all the world was serial terminals. In this new
world of GUIs this model doesn't work so well. I advocate changing it to
a queue of keypress events.