Backspace key not working in Vim/vi
Solution 1:
To allow backspacing over everything in insert mode (including automatically inserted indentation, line breaks and start of insert) you can set the backspace
option:
:set backspace=indent,eol,start
or
:set backspace=2 "compatible with version 5.4 and earlier
By default this option is empty, not allowing you to backspace over the above-mentioned things. This is the standard Vi behavior.
You can put this line to your vimrc
file to have it set automatically when Vim starts:
set backspace=indent,eol,start " more powerful backspacing
Also, starting from Vim 8.0 if no user vimrc file is found, Vim will set backspace
to this value by loading the defaults.vim
script.
Solution 2:
Like a linux-newb, I was on a fresh Ubuntu 18.04 install and my vim editor behaved differently than I was used to on the other machines I use (to include the backspace behavior you're describing). I didn't realize that I was actually using vi and not vim (both of which are executed with vi
).
Installing vim and then editing a file brought back the behavior I was used to, including the backspacing working like I was expecting.
sudo apt install vim