simont
simont

Reputation: 72527

vim not allowing backspace

File foo has text:

This| is a line.

If I place the cursor at the |, hop into insert mode, and press backspace, nothing happens. If I type something, I can delete the things I've typed, but only back to where the insertion began. For example, if I place the cursor at the end of the line, and type word, I can delete word but can't delete the . or anything to the left of it.

This is rather annoying. What vim setting does this?

Upvotes: 41

Views: 23714

Answers (2)

Diego
Diego

Reputation: 413

If you're using vim:

vim ~/.vimrc

If you're using vi:

vi ~/.exrc

Then add this line to the top of the file:

set nocompatible

Save the file and that should fix it

Upvotes: -1

David Cain
David Cain

Reputation: 17323

Explanation

The 'backspace' setting controls this behavior.

From the help page:

Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
mode.  This is a list of items, separated by commas.  Each item allows
a way to backspace over something:

value   effect
indent  allow backspacing over autoindent
eol     allow backspacing over line breaks (join lines)
start   allow backspacing over the start of insert; CTRL-W and CTRL-U
            stop once at the start of insert.

Changing backspace behavior

Try adding the following to your .vimrc:

set backspace=indent,eol,start " backspace over everything in insert mode

A short-hand version of the same command:

set backspace=2

Upvotes: 83

Related Questions