Backspace in Vim does not work

Soon I had a problem of the backspace key in vim. I am connecting to a remote machine through VNC. When I open Vim in Xterminal (xterm) and press the backspace key it prints ^? Instead of doing deleting the character before the cursor. I did waste few hours to find a fix and here it is:

In Vim when you press the backspace key it prints ^?
Solution 1
Try adding the following line in file .vimrc
set backspace=2
It did not work?
Solution 2
Add the following lines in your .vimrc file.
if &term=="xterm"
  set t_kb=<CTRL+V><BS>

<CTRL+V> means to press the control key and “V”. Not to type the string as is
<BS> means to press the backspace key
This combination of keystrokes will generate the code mapped to backspace key.
And all the lines above essentially will make proper correct mapping for the backspace key.

It did not work? Then, I don’t know how you can fix it.

Tags: , , , ,

{ 2 comments to read ... please submit one more! }

  1. Yet another solution:
    In your shell configuration file (e.g., $HOME/.zshrc for zsh), include the following line:
              # Solve problem with backspace in vim
             stty erase "^?"
    Hope this helps 😉

  2. Thanks man! I will try it, too :) It took me some time until I figure this out :)

{ 0 Pingbacks/Trackbacks }

Leave a Reply

Your email address will not be published. Required fields are marked *