TL;DR
This seems to be a bug in vim where set nocompatible is not idempotent and doesn't follow the principle of least astonishment.
As a workaround, either:
-
Ensure that you set nocompatible (or the equivalent set nocp) only once, and at the top of your vimrc.
-
Don't set it if it's already set:
if &compatible | set nocompatible | endif " Avoid side effects if `nocp` already set
Explanation and bug illustration
From :help compatible (empahsis mine):
This is a special kind of option, because when it's set or reset,
other options are also changed as a side effect. CAREFUL: Setting or
resetting this option can have a lot of unexpected effects: Mappings
are interpreted in another way, undo behaves differently, etc. If you
set this option in your vimrc file, you should probably put it at the
very start.
Note that &viminfo is not listed in the side-effects, however the following lines clearly show the side effect upon &viminfo:
set nocompatible
set viminfo+=nWatch-my-viminfo-file-location-be-ignored
echom &viminfo
set nocompatible " do side effects even though nocomptible is already set
echom 'After 2nd "set nocompatible":'
echom &viminfo
Output:
'100,<50,s10,h,nWatch-my-viminfo-file-location-be-ignored
After 2nd "set nocompatible":
'100,<50,s10,h
vim --version | head -1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 05 2016 16:48:20)
See also this question on Vi Stackexchange
TL;DR
This seems to be a bug in
vimwhereset nocompatibleis not idempotent and doesn't follow the principle of least astonishment.As a workaround, either:
Ensure that you
set nocompatible(or the equivalentset nocp) only once, and at the top of yourvimrc.Don't set it if it's already set:
Explanation and bug illustration
From
:help compatible(empahsis mine):Note that
&viminfois not listed in the side-effects, however the following lines clearly show the side effect upon&viminfo:Output:
vim --version | head -1See also this question on Vi Stackexchange