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:

  1. 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!

    ReplyDelete
  2. Glad to be of assistance ;)

    ReplyDelete
  3. Pleasure to be of assistance :)

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

    ReplyDelete
  5. Thank you soooo much! Saved me much frustration.

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

    ReplyDelete
  7. 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

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

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

    ReplyDelete
  10. 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)

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

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

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

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

    ReplyDelete
  15. 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

    ReplyDelete
  16. 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

    ReplyDelete
  17. 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

    ReplyDelete
  18. that was easy!! Thanks a lot

    ReplyDelete
  19. 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.

    ReplyDelete
  20. thanks for the tip Brian, hope I remember it !

    ReplyDelete
  21. 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?

    ReplyDelete
  22. Thanks for the handy solution. Great help.

    ReplyDelete
  23. 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!

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

    Thank you very much for your post ;-)

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

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

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

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

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

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

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

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

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

    ReplyDelete
  34. 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!!

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

    mv ~/.vimrc ~/.virc

    Worked for me.

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

    ln ~/.vimrc ~/.virc

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

    ReplyDelete