Reputation: 1036
I'm working on mappings in vim and ran into a problem. I can map to <Up>
, <Down>
, <Left>
, and <Right>
, and I can map to <S-Left>
and <S-Right>
, but I can't map to <S-Up>
and <S-Down>
. In other words
:nmap <S-Right> l
works, and so does
:nmap <Up> l
but
:nmap <S-Up> l
doesn't.
Maybe SO will know the answer to this problem, in which case I'll change the question title to be more specific. But failing that, I'd like commands I can use to diagnose what's failing where.
(if I broke your up key with the above command, type :unmap <Up>
)
Upvotes: 2
Views: 708
Reputation: 172590
The issue probably is with your terminal [settings].
What you can do to troubleshoot is trying to literally insert the keys received by Vim. In insert mode, type <C-V>
followed by the (shifted) cursor key. For me (gnome-terminal with TERM=gnome-256color
), I get these distinct values (so shifted cursor keys all work for me, yay):
" Up, S-Up, Down, S-Down
^[OA ^[[1;2A ^[OB ^[[1;2B
" Left, S-Left, Right, S-Right
^[OD ^[[1;2D ^[OC ^[[1;2C
If you see the same values for shifted and unshifted keys, your terminal doesn't distinguish between them, so Vim cannot, neither. The next step would then be to check your terminal settings / use a different terminal.
Upvotes: 4