You are not logged in.

#1 2009-05-03 22:01:52

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

[Solved] Urxvt, vim and ctrl + arrow keys

I just switched to rxvt-unicode - mostly because of its ability to set the WM_CLASS variable (Xfce's terminal, my previous terminal application, was unable to do so, and I was tired of dragging all my apps to the virtual desktop I wanted to have them on). So far so good, but I bumped into a problem I knew from a previous encounter with urxvt: it maps ctrl+left/right differently than xterm (and Xfce's terminal), and I can't jump words in Vi anymore.

I have been trying to map them in my ~/.virc to reproduce the behaviour, but that's not working (and I'm clueless why). This is the excerpt from .virc:

map ^[Oc W
map ^[Od B
map! ^[Oc ^[Wa
map! ^[Od ^[Ba

Ctrl+Left generates ^[Od, Ctrl+Right generates ^[Oc. Vi will put itself in insert mode (if it isn't already) when i press those combinations and insert a d or c, depending on the combination pressed, but no jumping words.

Does someone know what I'm doing wrong?


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#2 2009-05-03 22:35:56

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [Solved] Urxvt, vim and ctrl + arrow keys

B wrote:

Does someone know what I'm doing wrong?

You're using arrow keys with vi lol


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#3 2009-05-03 22:40:40

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [Solved] Urxvt, vim and ctrl + arrow keys

+1 for humour... I know the b/B and w/W keys, thank you. I don't like them.

Seriously... If that's all you can come up with, keep your hand off that post button and spare both of us the effort wink.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#4 2009-05-03 22:58:45

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [Solved] Urxvt, vim and ctrl + arrow keys

I'm sorry, I just couldn't resist wink
I'm not sure how you can fix that, if no one helps you before I wake up in the morning I'll look into it...

Last edited by moljac024 (2009-05-03 22:59:07)


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#5 2009-05-03 23:28:07

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [Solved] Urxvt, vim and ctrl + arrow keys

I guess it was too good a chance to let go indeed wink. Thanks.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#6 2009-05-04 01:26:00

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [Solved] Urxvt, vim and ctrl + arrow keys

The solution that RedHat uses is to modify /etc/inputrc. I assume that means that ~/.inputrc can be used also. These are the two lines that they added in the rxvt section for Ctrl <Right, Left>:

"\eOc": forward-word
"\eOd": backward-word

Offline

#7 2009-05-04 10:08:34

davvil
Member
Registered: 2008-05-06
Posts: 165

Re: [Solved] Urxvt, vim and ctrl + arrow keys

I had a similar problem with the alt-arrows key combination. I solved it by using following code in my .Xresources

URxvt.keysym.M-Down:        \033[1;3B
URxvt.keysym.M-Up:          \033[1;3A
URxvt.keysym.M-Left:        \033[1;3D
URxvt.keysym.M-Right:       \033[1;3C

I expect you can do something similar with the control-key combination. And of course, do not forget to load your .Xresources at the beginning of your X session if you are not doing this already!

Offline

#8 2009-05-04 10:25:14

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [Solved] Urxvt, vim and ctrl + arrow keys

As an alternative to making vi recognize urxvt's Ctrl-Arrow keycodes, these settings will make urxvt generate the same keycodes as xterm (usually) generates on Ctrl-Arrow:

URxvt.keysym.Control-Up   \033[1;5A
URxvt.keysym.Control-Down    \033[1;5B
URxvt.keysym.Control-Left    \033[1;5D
URxvt.keysym.Control-Right    \033[1;5C

Offline

#9 2009-05-04 15:44:38

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [Solved] Urxvt, vim and ctrl + arrow keys

@ davvil & hbekel: Awesome, I'll try that when I get back home and report smile.

skottish wrote:

The solution that RedHat uses is to modify /etc/inputrc. I assume that means that ~/.inputrc can be used also. These are the two lines that they added in the rxvt section for Ctrl <Right, Left>:

"\eOc": forward-word
"\eOd": backward-word

Skottish, I already have those in my ~/.inputrc. The thing is, I understood /etc/inputrc and ~/.inputrc are used by readline and apps using it, but vim is not one of them. Those sequences make Ctrl+Right/Left work like in xterm and similar terminals (Xfce's terminal e.g.) - you can jump words - but Vim won't pick it up, since it doesn't use readline.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#10 2009-05-04 22:49:35

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [Solved] Urxvt, vim and ctrl + arrow keys

Okay i'm happy to report it works smile.

I dropped those mappings in my .Xdefaults, reloaded them with xrdb, restarted urxvt, and behold... Ctrl+Left/Right works again big_smile. Thanks a lot!


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#11 2012-02-13 23:47:32

emmanuelux
Member
Registered: 2012-02-12
Posts: 7

Re: [Solved] Urxvt, vim and ctrl + arrow keys

thanks for :
URxvt.keysym.Control-Up:   \033[1;5A
URxvt.keysym.Control-Down:    \033[1;5B
URxvt.keysym.Control-Left:    \033[1;5D
URxvt.keysym.Control-Right:    \033[1;5C
you need the ":"

do you know other important keysym to modify to have urxvt again more compatible with vim

Offline

#12 2012-02-14 02:10:06

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,272

Re: [Solved] Urxvt, vim and ctrl + arrow keys

emmanuelux wrote:

thanks for :
URxvt.keysym.Control-Up:   \033[1;5A
URxvt.keysym.Control-Down:    \033[1;5B
URxvt.keysym.Control-Left:    \033[1;5D
URxvt.keysym.Control-Right:    \033[1;5C
you need the ":"

do you know other important keysym to modify to have urxvt again more compatible with vim

Don't necro-bump please, see here.

Closing.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB