Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim not allowing backspace

Tags:

vim

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?

like image 618
simont Avatar asked May 23 '12 20:05

simont


People also ask

Why is my Backspace not working in Vim?

To fix “not working” backspace key in the insert mode permanently, add set backspace=indent,eol,start command to vi / vim configuration file in your $HOME directory.

How do I turn on Backspace in vi?

Once in insert mode, you can type in your text. Press ENTER at the end of each line. Use Backspace to delete to the left of the cursor. If you need to move the cursor to another line, or make a change, or pretty much anything else, you need to press ESC to get back to Command mode first.

Do you use Backspace in Vim?

vi/vim editor FAQ: What is the vi/vim backspace key? In Vim, you delete the character under the cursor using the 'x' key while in command mode (which is the equivalent of a [delete] key), and to delete characters to the left of the cursor -- which is the equivalent of a vim backspace key -- use the capital letter 'X'.

Why is Backspace not working Linux?

Checking Terminal Settings with stty The -a flag will give a human-readable output of the control characters. Look for the "erase" character. If it says "^H," then it uses the older Backspace character. Fortunately, you can also fix this with the stty command.


1 Answers

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
like image 126
David Cain Avatar answered Nov 06 '22 03:11

David Cain