Reputation: 11002
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?
Upvotes: 1
Views: 1330
Reputation: 54563
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).
Upvotes: 5
Reputation: 195199
In vim, you can have:
set t_ku=^[OA
set t_kd=^[OB
set t_kr=^[OC
set t_kl=^[OD
(To get ^[OA
you press ctrl-v
then up
)
I use urxvt too, because it is fast, I don't use the transparency feature. In urxvt
you may want to set option keysym.sym: action
read man page for more details.
If you use vim, use vim motions, ctrl-U/D/F/B
or wWeEbB..
. You don't need the arrow keys at all. E.g. On my keyboard, pressing arrow keys I have to press an extra Fn
key.. too expensive, and my fingers have to leave the homerow.
In terminal, I suggest you getting used to emacs-binding
to edit command line, your word jumping would be: alt-b (back) and alt-f(forward)
There are a lot more, very common to use: ctrl-f, c-h, c-w, a-w,c-b,c-u,c-k,a-. etc .....
also man should not forget the c-xc-e
Upvotes: 1