Backspace key not working in Vim/vi

Viewed 125687

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.

9 Answers

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

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

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

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.

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

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.

Related