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?
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.
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.
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'.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With