1

Possible Duplicate:
vim backspace leaves ^?

My Vim Backspace is not working correctly. When I press it, it prints out ^?. I found some other suggestions on how to fix it such as adding set backspace=indent,eol,start to the .vimrc. But this does not seem to work right. Does anyone have any other ideas on how to fix this?

Thanks!

Community
  • 1
  • 1
Eman
  • 6,383
  • 4
  • 23
  • 29

2 Answers2

8

perreal's answer tells you how to alter the Linux console to match vim's current settings, but you also have the option of altering vim's settings to match the Linux console. The relevant options are t_kb and t_kD to tell vim what characters the terminal generates when you press the Backspace and Delete keys respectively. Query the current settings first so you can see what they're set to:

:set t_kb? t_kD?

and then change them like this:

:set t_kb=XXX t_kD=XXX

In place of the XXX's you should type Ctrl-V followed by Backspace for the first one and Ctrl-V followed by Del for the second one.

There's another question you could be asking, about why these settings weren't properly detected in the first place. If you're interested in investigating that, we'll need to see your $TERM variable and the corresponding terminfo database entry, which you can get with:

echo $TERM
infocmp | egrep 'kdch1|kbs'
Alan Curry
  • 14,255
  • 3
  • 32
  • 33
3

From vim-docs :help fixdel

Note about Linux: By default the backspace key produces CTRL-?, which is wrong. You can fix it by putting this line in your rc.local:

echo "keycode 14 = BackSpace" | loadkeys

perreal
  • 94,503
  • 21
  • 155
  • 181
  • Okay so I add this to my vimrc do I enter it in just the way you have it there? Or am I missing something? because when I enter it i the way you have it now, it says: E492: Not an editor command: loadkeys. What do you think? – Eman Jul 26 '12 at 16:58
  • you will add it to `rc.local` file. http://www.oreillynet.com/linux/blog/2007/08/etcrclocal.html – perreal Jul 26 '12 at 17:00
  • My rc.local is not letting me save the lines. It says it could not get the security context for the file. – Eman Jul 26 '12 at 17:26
  • Are you on Fedora? Try `setenforce 0` before modifying the file – perreal Jul 26 '12 at 17:37