Wednesday, March 8, 2017

Re: viminfo file location for Vim 8

On Tue, Mar 7, 2017 at 3:52 PM, David Fishburn <dfishburn.vim@gmail.com> wrote:
>
> On Thu, Jan 26, 2017 at 8:52 AM, David Fishburn <dfishburn.vim@gmail.com>
> wrote:
>>
>> I use the following line in my vimrc (Windows):
>>
>> set
>> viminfo=\"50,'500,:500,/500,h,f1,rA:,r$TEMP:,r$TMP:,r$TMPDIR:!,n$VIM/_viminfo
>>
>>
>> For Vim 5,6,7 this works as expected and the _viminfo file is created in
>> my $VIM root directory.
>>
>> When I upgraded to Vim 8, now the _viminfo is being created in whatever
>> directory I launched Vim from. I have been through the docs and do not see
>> what might be causing it.

I'm surprised by this affirmation. By default, the viminfo is read and
written in your $HOME directory instead, or, on Windows only, in $VIM
if $HOME is not set.
>
>
>
> I finally tracked this down to a new Vim 8 feature.
> I use a System vimrc ($VIM/vimrc) rather than a user vimrc ($HOME/.vimrc).
>
> So Vim 8 started sourcing a defaults.vim on me.
>
> This is documented here:
> Defaults without a .vimrc file ~
> *defaults.vim*
> If Vim is started normally and no user vimrc file is found, the
> $VIMRUTIME/defaults.vim script is loaded. This will set 'compatible'
> off,
> switch on syntax highlighting and a few more things. See the script for
> details. NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was
> added in
> patch 7.4.2111 to be exact).
>
>
> I figured this out, after noticing despite me setting the viminfo option, it
> was changed.
> :verbose set viminfo
> viminfo='100,<50,s10,h,rA:,rB:
> Last set from C:\Vim\vim80\defaults.vim
>
>
> I added the following to my $VIM/vimrc file:
> " Vim 8, prevents defaults.vim from being sourced
> let skip_defaults_vim = 1
>
> Hope this helps others on the list and updates all the people who monitor
> and respond to this list as another item to check if someone else complains
> about it.
>
> David

The problem is that your system vimrc is sourced too early (see :help
startup) and that, as you found out, if you don't have a .vimrc Vim
sets its "new defaults", similar to what the vimrc_example.vim used to
do; but this happens when looking for a user vimrc and not finding
one, thus after the system vimrc (if any) has been sourced.

If, as is recommended, you had put your user defaults in a "user
vimrc" (in your $HOME directory, thus applying only to you), not in a
system-wide "system vimrc" (applying to every login name on your
system), you wouldn't have had this problem.

If you have a user vimrc, sourcing the vimrc_example.vim from it will
still implicitly source the defaults.vim too, but after that point in
your vimrc you can override any default that doesn't suit you. For
instance I use "filetype indent off" when coming back from sourcing
the example vimrc, because I don't like the way Vim does
autoindenting. As for the viminfo, having it in $HOME suits me so I
don't set its name, I just use

if has('viminfo')
set vi='500,!,%,c
if has('unix')
set vi+=r/mnt/
endif
endif " +viminfo


Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: