Cygwin Terminal backspace and arrow keys not working

10

5

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.

CodeIt

Posted 2014-11-23T06:45:54.333

Reputation: 1 485

Answers

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

crobicha

Posted 2014-11-23T06:45:54.333

Reputation: 226

1I wonder if anyone uses the defaults! – dashesy – 2015-12-17T22:13:47.023

This is by far the best answer! – hopeseekr – 2016-03-27T14:32:09.820

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.

Kamil

Posted 2014-11-23T06:45:54.333

Reputation: 2 524

Thanks was slipping on the m of .virc vs .vimrc – Ujjwal Singh – 2016-03-08T21:30:16.383

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

CodeIt

Posted 2014-11-23T06:45:54.333

Reputation: 1 485

3Note that "vi -N" is the same as setting "set nocp" or "set nocompatible" in your ~/.vimrc file. – tgharold – 2015-05-07T17:29:54.973

1@tgharold I tried with set nocp but it didn't fix the issue so i tried an alternate method. – CodeIt – 2015-05-08T14:28:58.617

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

timiscoding

Posted 2014-11-23T06:45:54.333

Reputation: 21

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.

Samuel

Posted 2014-11-23T06:45:54.333

Reputation: 113

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!

eresonance

Posted 2014-11-23T06:45:54.333

Reputation: 203