Why does the behavior of Backspace change in vim with SSH?

When I'm accessing one particular machine through ssh, the behavior of Backspace in vim changes. Instead of deleting chars, i have a ^? .

The problem is this machine acts as gateway and this problem is propagated when i'm accessing any machine behind this gateway (when I'm ssh-ing any of these machines inside the domain -without going through the domain-, i don't have this problem)...

This is not a big deal but it's really annoying.

Any idea ?


Solution 1:

It's usually a mismatch between what's configured in you shell and what's configured in your terminal emulator.

Some use backspace (0x08), some use DEL (0x7f). If, from within your terminal session, you run

stty -a

you'll see a line like:

intr = ^C; quit = ^\; erase = ^?; kill = ^U; ...

That erase is the DEL character. You need to either configure your SSH to transmit that character or do a:

stty erase '^H'

to change the shell.

I know that Putty, for one, can change the character transmitted when you hit the backspace key. I think it's buried in the terminal section somewhere (at least in v 0.58) but I don't have Windows handy to check it.

However, it's not really programming-related so you may find this gets shifted over to superuser.com.