Recently I started to use & favor urxvt
due to its vast amount of options and because of the transparency feature.
Unfortunately, some key mapping in Vim
do not work in urxvt
.
For example, I have mapped Ctrl + Up/Down
and Shift + Up/Down
to 5 respectively 10 lines up/down movement or Ctrl + Left/Right
to 1 word left/right movement.
These movement commands do work without any problems in xterm
, but they refuse to work in urxvt
: they switch to insert mode and paste a
, b
, c
or d
as input into my vim.
Why does this happen?
I also use zsh
as my shell and mapped Ctrl + Left/Right
to move 1 word left/right in zsh
: this also stopped working in urxvt
(while still working in xterm
).
How can I get urxvt
to correctly map the keys?
From the description of the problem you probably overlooked the fact that key definitions in urxvt differ from xterm. Unless you specially configure urxvt, its special keys (cursor- and keypad-keys) send different escape sequences than xterm when you modify those with shift, control, alt.
You can either use the escape sequences which urxvt sends, or you could use the keysym
feature to configure urxvt to send comparable escape sequences. This feature was introduced by rxvt, and extended with urxvt to allow you to specify the modifiers (shift, control, etc), which you might want to limit the keysym
to apply on:
keysym.sym: string
Compile frills: Associate string with keysym sym. The intervening resource name keysym. cannot be omitted.The format of sym is "(modifiers-)key", where modifiers can be any combination of ISOLevel3, AppKeypad, Control, NumLock, Shift, Meta, Lock, Mod1, Mod2, Mod3, Mod4, Mod5, and the abbreviated
I
,K
,C
,N
,S
,M
,A
,L
,1
,2
,3
,4
,5
.
That "compile frills" is a hint that it's an optional feature. However most packagers appear to turn on all of its options (except where they conflict). So it's probably available to you.
There's an overview of the topic (of the escape sequences) in the ncurses FAQ How can I use shift- or control-modifiers? (vim incidentally doesn't use ncurses or the modifier information in the terminal database—it's a termcap application—but that's a different problem).