Fixing Backspaces
September 21, 2006
One annoyance of working with Sun machines is that the backspace key never seems to map in such a way that vim can understand it. The usual way to fix the behavior of the backspace key, as told by :help fixdel, is to issue the following at the vim command line or put the following in your .vimrc:
:set backspace=2
Or:
:fixdel
However, this doesn’t work if the signal being passed from your keyboard to your terminal to vim is incorrect, as it was for me. So, the symptoms of “My terminal acts appropriately on the command line, but in vim backspace produces ^?, and :set backspace=2 and :fixdel don’t fix it” can be solved with a quick line issued at the command prompt:
stty erase ^?
It is important to note that ^? does not mean typing ^ and then ?, it means hitting ‘ctrl-v’ and then ‘?’. Try it: you’ll see the output matches mine. The reason for this is ctrl+v is telling the terminal to capture the signal recieved by the keypress instead of the actual keypress after it has been interpreted. The command above is actually forcing the terminal to interpret the ^? signal as the erase function, which is the effect you want bound to your backspace key.
Remember, if it works, put it in your rc files (such as ~/.bashrc for you bash users) so it will magically work every time you login.
