Can terminals detect <Shift-Enter> or <Control-Enter>?
Gvim runs its own manager for keystroke handling and so can pick up all the various key combinations. Vim is reliant on the specific terminal for passing on the particular keypress, so keyhandling is only as good or varied as the terminal is.
One way you can find out whether you can do what you want to do is to use the key to find out what is inserted. eg Type:
:<C-V><C-Enter>
ie actually type in the combination you want to press after having typed the combination Control-V. After that do the same thing for enter, ie
:<C-V><Enter>
If they yield the same code, then the terminal interprets both key combinations as the same keycode, and you can't bind them without messing with the terminal.
In my terminal (urxvt), Control-Enter, Shift-Enter and Enter (by itself) all produce the ^M character, meaning I can't map one without mapping the other. The same goes for Control-Tab and Control-I, and Control-Space and Control-@
EDIT: Use C-Q instead of C-V for Windows.
Some terminals send <NL>
when <C-Enter>
is pressed. This is equivalent to sending <C-J>
.
To find out what your terminal does with <Shift-Enter>
, <Ctrl-Enter>
and <Enter>
, go to your terminal, type <Ctrl-V>
(similar to sykora's suggestion for vim), and type in the sequence you're interested in.
Using gnome-terminal, I get the following:
<Enter> : ^M
<S-Enter> : ^M
<C-Enter> : <NL>
Looking at man ascii
indicates that ^M
gives the <CR>
sequence.
The answer is that it depends on the terminal, and there's an easy way to check.