Monday, July 04, 2005

Using the Backspace Key in vim

The Fedora Core 3 version of the vi-clone text editor vim let you use the backspace key to delete the character you just typed, just like an old-style keyboard/typewriter.

In Fedora Core 4 the default is that the backspace key is the same as Ctrl-H, like on an old style teletype. To fix this, it's necessary to edit the ~/.vimrc file, adding the line:

inoremap ^? ^H

Actually, to type that using vim, you press the keys:

inoremap Ctrl-V Ctrl-Shift-? Ctrl-V Ctrl-h

as Ctrl-V means: insert the next key I press literally, dummy.

This makes vim behave the way it should in insert mode: Pressing the backspace key (or Ctrl-H) deletes the character you just typed.


Anonymous said...

Thank you, thank you, thank you!!

holly said...

Actually I had to do this:

inoremap ctrl-v backspace ctrl-v ctrl-h

rcjhawk said...

Yeah, it looks like Fedora's default keyboard maps backspace to ^-? (Ctrl-Shift-?)