backspace not working, even after attempted fix

7

2

I tried following the instructions in Backspace key not working in vim , but I still have the same problem: BACKSPACE inserts a ^?

That is to say: inserting set bs=indent,eol,start in my ~/.vimrc did not solve the problem.

I am sure that I am loading the correct source file (I did a test of another setting, and the change propagated).

I am using: Vi IMproved 7.2 on Ubuntu with Gnome. In the terminal application, backspace works properly.

dsg

Posted 2011-06-02T01:32:42.207

Reputation: 1 019

Answers

6

Vim seems to be confused about what your terminal sends as the erase character. As this varies between ^? (Ctrl+?, or DEL for "delete") and ^H (Ctrl+H or BS for "backspace"), Vim depends on someone telling it what to expect.

That shouldn't happen unless

  • you're changing related settings in your vimrc,
  • you're changing the value of the TERM environment variable,
  • your terminal information database is messed up, or
  • you're suffering from a gremlin infestation.

For troubleshooting, try to run the command stty erase ^? before starting Vim, and see if this fixes it. Enter the ^? not separately as ^ and ?, but by first pressing Ctrl+V, then your Backspace key. If your shell is well-behaved, this should produce a literal representation of whatever your terminal sends when you hit that key.

peth

Posted 2011-06-02T01:32:42.207

Reputation: 7 990

Thanks, stty erase ^? worked for me. I added it to my .bashrc file. – dsg – 2011-06-03T02:50:29.830

1

If you are using gnome-terminal then there should be a setting to have backspace emulate ^H. There are similar settings in other terminal emulators; it's the first place I would go since no one else has mentioned it.

Accessing profile in gnome-terminal

Setting backspace behavior

elcash

Posted 2011-06-02T01:32:42.207

Reputation: 166

1

Found this question while searching for something mildly related, and thought I'd post a pedantic (but possibly helpful) follow-up.

Most modern versions of stty(1) (including the version shipped with GNU Coreutils) interpret the two-character sequences ^ ? and ^ h as the control sequence ASCII DEL and ASCII BS (respectively). Or more generally, two-character sequences starting with ^ as their equivalent ASCII control character.

So the two following commands are equivalent:

stty erase '^?'
stty erase ^VDEL

David Klann

Posted 2011-06-02T01:32:42.207

Reputation: 11

0

Try adding the following to your .bashrc ( or .profile )
stty erase ^H
That is the character "^" followed by the character "H"
--or--
If that does not work, to get "^H" type control-V followed by control-H

See vim help
:help gui-pty-erase

broomdodger

Posted 2011-06-02T01:32:42.207

Reputation: 1 810