3

I'm having a weird issue with vim on Ubuntu. I've been using it for the last few weeks, trying to learn, on Windows and it behaves differently now that I'm using it on Linux.

I noticed that while in insert mode pressing backspace will delete text just like any other editor on Windows, but on Linux the text is "deleted" yet it stays there until I press ESC or write over it.

I was trying to fix this but I'm confused as to whether this is intended behaviour or not. It happens in gvim too.

The reason of this question is this, however:

I deleted my .vimrc file to see if any of my config was at fault and it fixed it. Backspace was now back to its regular self.

But then I tried creating an empty .vimrc file and that made it go back to the delayed delete. It's empty. Why the hell?

So I have no idea what's causing this. Hope my question makes sense my English ain't the best. Thanks.


Alright so looking at :h compatible I found this:

"When a |vimrc| or |gvimrc| file is found while Vim is starting up, this option is switched off, and all options that have not been modified will be set to the Vim defaults. Effectively, this means that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim defaults, otherwise it will use the Vi defaults. (Note: This doesn't happen for the system-wide vimrc or gvimrc file, nor for a file given with the |-u| argument). Also see |compatible-default| and |posix-compliance|."

So if I'm getting this right, running Vim with a .vimrc file should automatically set nocompatible and running it without one should set compatible... ? Whatever the case, I tried checking with :verbose set compatible? and it always says nocompatible is on so the -N flag shouldn't do anything... Yet it fixes the issue.

Mxx
  • 31
  • 3

2 Answers2

3

Without a vimrc Vim will load /usr/share/vim/vim80/defaults.vim (depending on your vim version). In this file the bs/backspace parameter is set to 2, or actually it is indent,eol,start which is the same as 2 (see :h bs)

Now if you create an empty .vimrc, defaults.vim will not be loaded, so your bs will possibly be 0.

This behaviour is described in :h defaults.vim

So to solve your problem, just put set bs=2 in your .vimrc

Doktor OSwaldo
  • 5,732
  • 20
  • 41
0

Alright I fixed it.

Running vim with the -N command makes it work properly. I'm not sure why but that's what's happening.

Mxx
  • 31
  • 3
  • something is strange here, how do you nromaly start vim? The `-N` flag sets nocompatible, which vim actually does automatically if a `.vimrc` is present (see `:h cp`). Please start your faulty vim again, and put the output of `:verbose set cp?` in your question – Doktor OSwaldo Nov 02 '17 at 13:51
  • I run vim and gvim using the terminal. I'm not in class anymore so I wont be able to test any other solutions until tomorrow. All I know is that running vim -N fixed that error. The reason I tried it was because the emmet plugin was giving me some error about backslashes not being expected or something, so I found a thread in here where someone suggested the -N mode. It fixed both the emmet error and the backspace. Other than the emmet plugin and pathogen I ain't running any other plugins. – Mxx Nov 02 '17 at 16:13
  • have you tried to deactivate the emmet plugin? also what terminal do you use? have a look at [:h fixdel](http://vimdoc.sourceforge.net/htmldoc/options.html#:fixdel) – Doktor OSwaldo Nov 03 '17 at 07:07
  • I installed emmet afterwards so that's not the issue anyway. I edited my main post with some more info about the issue but, whatever the case... I just purged vim from the computer and reinstalled it. It somehow works now. I'm done. – Mxx Nov 03 '17 at 09:12