10

The arrow keys returns A,B,C,D and my backspace key are not working properly . This problem happens only with the vi editor.Is there any way to solve this issue on Cygwin ?

I did find possible duplicates for this question but i was not able understand . Someone please provide me step-by-step instruction for an absolute beginner like me.

11

The best answer I have found so far is to copy Cygwin VIM's sample vimrc file:

cp /usr/share/vim/vim*/vimrc_example.vim ~/.vimrc

Solves all of the weird keymap issues I was seeing plus adds some extras like syntax highlighting.

Source

  • 1
    I wonder if anyone uses the defaults! – dashesy Dec 17 '15 at 22:13
  • This is by far the best answer! – hopeseekr Mar 27 '16 at 14:32
7

Here is simple solution for this.

This is about vim and remote shell, but it should work.

Fix arrow keys that display A B C D on remote shell

It says:

1) Open Vim editor,
2) Get the path of your home directory by typing :echo $HOME
3) Check if you have .vimrc file in $HOME location,(if you don't have create it)
4) Add the following line line to .vimrc file
   set nocompatible
        or
   set nocp

If you have vi (not vim) - configuration file is .virc not .vimrc.

  • Thanks was slipping on the m of .virc vs .vimrc – Ujjwal Singh Mar 8 '16 at 21:30
3

I did like this and it has fixed the problem . Open vi editor from $home using :

vi -N .bashrc

then scroll down to the bottom or start a new line, Now in Insert Mode type

alias vim='vi -N'

Now as usual save the file. Type

:wq 

It will fix the issue..

  • 3
    Note that "vi -N" is the same as setting "set nocp" or "set nocompatible" in your ~/.vimrc file. – tgharold May 7 '15 at 17:29
  • 1
    @tgharold I tried with set nocp but it didn't fix the issue so i tried an alternate method. – CodeIt May 8 '15 at 14:28
2

I'd like to add that the solution offered by Kamil fixes the arrow key problem.

However, the backspace problem remained. The solution found here is to add the line

set backspace=2

to ~/.vimrc

0

In case you copy your .vimrc from a customized version on a linux computer, you may have run into the same term setting issue I did.

If you have this in your .vimrc:

set term=xterm

Change it to be automatic:

set term=$TERM

And then enjoy your arrow keys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.