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.


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.


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

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
   set nocp

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

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

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


It will fix the issue..

  • 4
    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

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


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!


I had this problem trying to run CygWin Bash using ConEmu opening a new console in a new tab, and the other answers didn't help me. The arrow keys worked fine except in shell tools (i.e. mongo). There, the arrow keys were mapped as A (up), B (down), C (right) and D (left).

In ConEmu window, navigate to:

Elipsis Menu (three bars) > Settings > Startup > Tasks

And locate the CygWin Bash entry in the Predefined tasks list: {Bash::CygWin bash} In the lower text area I initially had the following that caused the problem of the arrows:

set CHERE_INVOKING=1 & set "PATH=%ConEmuDrive%\tools\cygwin\bin;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe -new_console:p %ConEmuDrive%\tools\cygwin\bin\bash.exe --login -i -new_console:C:"%ConEmuDrive%\tools\cygwin\Cygwin.ico"

I changed it to the following and the arrows worked:

-new_console:p %ConEmuDrive%\tools\cygwin\bin\bash.exe --login -i -new_console:C:"%ConEmuDrive%\tools\cygwin\Cygwin.ico"

If you are creating new file in cygwin, do this it worked for me: create the file by command: vi -N one.c instead of vi one.c


Which version of vi are you executing?

I had the same problem. I was running Vim compiled against MINGW in a cygdrive console.

The solution was to install the CygWin version (from the CygWin setup utility) and it worked as expected.

There are different Vim versions for Windows. To the best of my knowledge, the MINGW and CygWin versions are not fully compatible, given that Vim's MINGW version is compiled natively for windows but Vim's cygdrive version is emulating a POSIX (cygwin.dll), reason by which the keyboard mappings are not understood each other.

Running versions of software compiled to one of the environments in the other one causes runtime errors.


After trying some of the other solutions with no success, I closed my Cygwin terminal and reopened a new one and voila, it worked.

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.