11

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.

12

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

| improve this answer | |
  • 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
9

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.

| improve this answer | |
  • Thanks was slipping on the m of .virc vs .vimrc – Ujjwal Singh Mar 8 '16 at 21:30
4

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

| improve this answer | |
  • 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

| improve this answer | |
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!

| improve this answer | |
0

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

| improve this answer | |
0

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"
| improve this answer | |

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.