Vim Tips Wiki

Backspace and delete problems

Revision as of 10:08, September 5, 2013 by (Talk)

1,619pages on
this wiki
Tip 68 Printable Monobook Previous Next

created 2001 · complexity basic · version 6.0

On some systems, you may experience problems using the backspace or delete keys. This tip discusses the causes and solutions. Generally, these problems arise on Unix-based systems because of the wide variety of hardware and software involved.


  • Following is a rough merge from some mysterious tips.
  • Need to reword and clarify what each is talking about.

Backspace key won't move from current line

Backspace works in Insert mode (e.g. not inserting a ^?), but won't delete over line breaks, or automatically-inserted indentation, or the place where insert mode started:

set backspace=2 " make backspace work like most other apps

Alternately, add this to your .vimrc:

set backspace=indent,eol,start

See :help 'backspace'

Strange characters are inserted

Backspace just puts weird characters in my file.

See :help :fixdel.

There's also a bug in xterm (at least v224) that may bring other users into the same backspace problem. Here's the link:

Well your Fucked

Checking for bad mappings

Your backspace key may be broken due to a bad mapping which has been loaded into Vim. This may be unintentional; Vim sees CTRL-H as a backspace (because CTRL-H is the ASCII code for a backspace), so you also cannot map anything to that. You can check if there are any mappings set, and where they came from, like this:

:verbose imap <BS>            " show insert-mode mapping for Backspace key
:verbose imap ^H              " insert this with Ctrl+V then Ctrl+H

If you find a mapping you can try clearing it with:

:iunmap <BS>                  " remove insert-mode mapping for Backspace key

If you want to create your own emergency mapping, you could try:

:imap ^H <Left><Del>          " map Ctrl+H to move left and delete the char

If you want an even more authentic mapping for a malfunctioning Backspace key, try this function:

func Backspace()
  if col('.') == 1
    if line('.')  != 1
      return  "\<ESC>kA\<Del>"
      return ""
    return "\<Left>\<Del>"

And add put this mapping into your .vimrc:

inoremap <BS> <c-r>=Backspace()<CR>

See also


Might want to add following info somewhere in tip:

On many Linux systems, running in an xterm window:

  • Backspace key emits <BS> (8 or ^H)
  • Ctrl-Backspace key combination emits <Del> (127 or ^?)

Around Wikia's network

Random Wiki