Thursday, June 02, 2005

Cygwin / vim / rxvt arrow key problems

On my new machine I installed cygwin, the great set of unix tools for win32, (BTW this is what makes using a win32 machine acceptable IMHO, it just works like a unix box...) and as usual in vi (or vim) my arrow keys pop me out of insert mode and then insert a newline and 'A' 'B' 'C' or 'D' - very annoying.

So the search started.... and I remembered the simple solution from the last time. People say in this situation that it is your terminal, and not vim that is misconfigured. I'm not sure I believe that, because the fix includes vim.

All you need to do is modify your .vimrc file. Copy the example .vimrc file from /usr/share/vim/vim62/vimrc_example.vim to ~/.vimrc then open vi and its fixed :)

Great, thats what we like - annoying problems, simple solutions

52 comments:

FyberOptic said...

Goodness, so much has this problem plagued me, but I didn't realize it was so easy to fix. I stumbled onto this page via Google when trying to find a solution again, as a matter o' fact. I'll certainly remember this from now on. Thanks for the tip!

Simon said...

Glad to be of assistance ;)

Simon said...

Pleasure to be of assistance :)

pipatron said...

Great. I find this page *after* I found out about the solution myself.

Sidewinder said...

Thank you soooo much! Saved me much frustration.

Unknown said...

Wow, fan-tastic! Could not thank you enough, this has been driving me crazy for quite a while!

Simon said...

No problem ;)

The Lightning Stalker said...

I was having this exact same problem with rxvt under msys/MinGW. It boils down to vim defaulting to Vi compatible mode. This is due to there being no .vimrc file. Making one with something like this should fix the problem.

set columns=80
set wrapmargin=8
set ruler

The Lightning Stalker said...

I should add also that setting backspace=2 will solve the funny backspace problems.

John Francis said...

So maybe even "touch ~/.vimrc" will do the trick?

Simon said...

I'm not sure, anytime I have to install cygwin I just copy the whole file. There are a lot of good settings in there (syntax highlighting etc)

Jason said...

Still feeling the love in 2009. Thanks for the tip.

ambar said...

Thanks! You saved me too! Even more than 4 years on from your original post!

Edobashira said...

Thanks worked great!
On a more recent version of cygwin vim62 is now vim72

Unknown said...

Thank you very much!

Anonymous said...

Wonderful. Wish I'd seen this around, oh, when you posted it. Thank you thank you thank you

Anonymous said...

Thank you soooooooooooooooo much.....for last 3 hours i was googling and trying to fix this problem n finally this blog came for my rescue

Unknown said...

Hi Simon,
I have been using linux since last 1 year but when i configured my new pc then this problem came...thanks a lot dear for ur support

Unknown said...

Hi Simon,
I have been using linux since last 1 year but when i configured my new pc then this problem came...thanks a lot dear for ur support

PV said...

that was easy!! Thanks a lot

Brian Enigma said...

For what it's worth, this mainly boils down to having a "set nocompatible" line toward the top of the file. The "set backspace=indent,eol,start" probably helps out, too. You can temporarily get the same non-vi-compatibility without a .vimrc (e.g. if you're at a coworker's machine) by running vim with the "-N" flag or by typing ":set nocompatible" in command mode.

Simon said...

thanks for the tip Brian, hope I remember it !

chrisbuzby said...

There was no default file for me to copy, so I used the suggestion of creating a new file with the followign lines:

set columns=80
set wrapmargin=8
set ruler
backspace=2

Worked like a charm, now can you fix my running powershell from cygwin issue?

Transducer said...

Thanks for the handy solution. Great help.

Sam said...

Thank you for your post, I have used vim under cygwin for long time. And today it really annoys me, and found your post. It fixed my long time problem. Thank very much!

Rafael said...

Thanks a lot!

Simon said...

You are most welcome :)

Luis Pinto said...

Funny as, 7 years after this being written, it is still very usefull ;-)

Thank you very much for your post ;-)

asheesh malik said...

Thank's a lot

SacrosanctBlood said...

Thanks a lot!!!! (Its 2012!!)

ALOK SHUKLA said...

thanks a lot simon

Simon said...

You're welcome!

cosjav said...

This is an awesome post. Such a simple solution! Thanks mate ;-)

Simon said...

no problem!

SHRAVAN15791 KUMAR VERMA MUMBAI said...

thanxx a lottt.............!!!!

Simon said...

you're welcome!

Ran said...

Had this problem just now.. Solved, thanks!!

Simon said...

You're welcome!

Unknown said...

wow, 7 years down the road and it's still an effective solution. Thanks Simon!!

Unknown said...

Seven years down the road and it's still an effective solution. Thank Simon!!

Gaurav Meena said...

thanks for solution

Paul Neve said...

Just to MeToo what Anthony Bouttell said. 7 years later and awesome post is still awesome. Many thanks.

Shalom Shachne said...

Thanks a kajillion! That was a ridiculously easy fix to a real painful problem!

pasknani said...

Can you create a video for it because me and my friends are not getting how to get this!!!!

pasknani said...

Can you create a video for it because me and my friends are not getting how to get this!!!!

Sh. said...

Many thanks! It solved the nagging arrow issue on my machine :)

Unknown said...

Thankyou so much for this fix! This has been frustrating me to no end - having vim running normally is like a breath of fresh air. Thankyou!!

Robert said...

If you find that vim does not parse the .vimrc file, rename it to .virc and try again.

mv ~/.vimrc ~/.virc

Worked for me.

Unknown said...

Or link the two so any changes are read regardless of what .vi* file gets parsed.

ln ~/.vimrc ~/.virc

The GNU School said...

Thank you!

BR,
Govind

Kursi Suresh said...

Thanks a lot. . . It was of gr8 help.

Arun Raghunath said...

Thanks a lot boss..