I'm trying to change the location of the viminfo
file.
Why does the value of &viminfo
revert after it is set in vimrc
?
TL;DR:
In my vimrc
I have:
set nocompatible
exec "set viminfo+=n".expand($XDG_DATA_HOME)."/vim/viminfo"
echom &viminfo
I've noticed that echo &viminfo
from command mode shows the previous version of &viminfo
even though the echom
inside vimrc
shows that &viminfo
was correctly (but temporarily) updated.
I'd suspect autocommand
, but ag -ul viminfo
only shows my vimrc
and the viminfo
file itself.
Why does the value of &viminfo
change after I explicitly set it?
Full description
@ravi@boxy:~$ vim --version | head -1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 05 2016 16:48:20)
I start vim
with VIMINIT set to honour the XDG Base Directory Specification
@ravi@boxy:~$ echo $VIMINIT
let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc"|set nocp|exec "set viminfo+=n".expand($XDG_DATA_HOME)."/vim/viminfo"|echom &viminfo|source $MYVIMRC
@ravi@boxy:~$
For belts and braces, I also have in my vimrc
:
set nocompatible
" Location of the viminfo file
exec "set viminfo+=n".expand($XDG_DATA_HOME)."/vim/viminfo"
echom &viminfo
Now I remove the existing ~/.viminfo
, start vim
, then exit:
@ravi@boxy:~$ rm ~/.viminfo
@ravi@boxy:~$ vim
'100,<50,s10,h,n/home/ravi/.local/share/vim/viminfo
'100,<50,s10,h,n/home/ravi/.local/share/vim/viminfo
Press ENTER or type command to continue
@ravi@boxy:~$ file ~/.viminfo
/home/ravi/.viminfo: ASCII text
@ravi@boxy:~$
The &viminfo
variable gets printed twice because of the belt and braces, but as you can see, the file is still created at the default location.