Backspace key not working in Vim/vi


Vim Problem Overview

I just did some changes to the .vimrc file and .bash_aliases file and from that time I can't delete words with backspace key.

My .vimrc file has:

set nocompatible

set number
set incsearch
set autoindent
set ruler
set autowrite
set smarttab
set linebreak
set spell
set et
set title

set mouse=v
set history=50
set tabstop=4
set matchtime=2
set matchpairs+=<:>

syntax enable
filetype plugin indent on
filetype indent on
set sw=4

map <f2> :w\|!python %

hi SpellBad ctermfg=000 guifg=#000

And my .bash_aliases file has two line for Vim:

alias vim="vim -c 'startinsert' -u ~/.vim/.vimrc"
alias vi="vi -c 'startinsert' -u ~/.vim/.vimrc"

My ~/.vim directory doesn't have a single plugin or script, so there's isn't any chance that plugin will cause this.

~/.vim/.vimrc is a symlink. The actual .vimrc file is in ~/vimrc/ directory which is a git repository.

Vim Solutions

Solution 1 - Vim

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


: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 - Vim

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

Solution 3 - Vim

My ~/.vimrc file had content set nocompatible. Added another line to the same file to make backspace work -

set backspace=indent,eol,start

And just run

source ~/.vimrc

in the same terminal for change to take immediate effect in same shell. No need to open vi and run

:set backspace=indent,eol,start

Solution 4 - Vim

For me,I had the setting below, however the backspace still doesn't work. >set backspace=indent,eol,start

Finally, I found following line led to this problem. >inoremap <expr><C-h> neocomplete#smart_close_popup()

When this setting is deleted, backspace key works well in insert mode.

Reason: That's because Vim sees CTRL-H as a backspace, and this line makes remapped to neocomplete#smart_close_popup() in insert mode.

Solution 5 - Vim

I had the same problem on a Debian 7.8 over SSH in urxvt + tmux. I had vim and vim-tiny installed.

Removing vim-tiny fixed the problem.

Solution 6 - Vim

I have compiled vim8.2 from source.Then I encouter this problem. After insert source $VIMRUNTIME/defaults.vim in .vimrc. BackSpace works.

Solution 7 - Vim

For me (Debian server, connected with "Konsole" from other linux), problems with backspace key and arrow keys were solved after uninstalling the vim-tiny package and installing the vim package.

Solution 8 - Vim

Many a times it is also a function of the getty type selected if one is using an SSH client like Putty or some such. Most preferable would be to use vt100+ as it is the most standard emulation.

I already had :fixdel which was not working. I had to remove it and replace it with the first suggestion to get it to work

Solution 9 - Vim

Nothing from above worked for me. Tried CTRL+backspace it saved me


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSantosh KumarView Question on Stackoverflow
Solution 1 - VimEugene YarmashView Answer on Stackoverflow
Solution 2 - VimMatt KleinView Answer on Stackoverflow
Solution 3 - VimAniket ThakurView Answer on Stackoverflow
Solution 4 - VimEchoView Answer on Stackoverflow
Solution 5 - VimliloroxView Answer on Stackoverflow
Solution 6 - VimBugKillerView Answer on Stackoverflow
Solution 7 - Vimjm009View Answer on Stackoverflow
Solution 8 - VimHighOnMeatView Answer on Stackoverflow
Solution 9 - VimashishView Answer on Stackoverflow