Vim Tips Wiki
Advertisement
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.

 TO DO 

  • 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, but won't delete over line breaks, or the place where insert mode started, or over automatically-inserted indentation:

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

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: http://bugs.gentoo.org/show_bug.cgi?id=154090.

Delete key problems

From :help :fixdel:

If your delete key terminal code is wrong, but the code for backspace is alright, you can put this in your vimrc:
:fixdel
This works no matter what the actual code for backspace is.
This is, at best, horrifically misleading. In particular, this will break things for Linux users, and for any other Unix system that has "seen the light". For most modern terminal emulators, <BS> sends ^? and <Del> sends ^[[3~ - and putting :fixdel into your .vimrc will change t_kD from the correct ^[[3~ to the incorrect ^H.

For many terminal emulators, Backspace will send either <C-?> or <C-h>, and Ctrl-Backspace will emit the other. So, if you don't want to spend the time to fix your settings, you might be able to work around your problems using ctrl+backspace instead of backspace.

See also

Comments

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 ^?)

Advertisement