Thursday, March 9, 2017

Re: viminfo file location for Vim 8



On Wed, Mar 8, 2017 at 4:40 PM, Bram Moolenaar <Bram@moolenaar.net> wrote:

David Fishburn 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 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.

But 'viminfo' isn't set in defaults.vim.  What does happen is that
'nocompatible' is set.

I can see that this is very confusing, and/or will result in many users
disableing the use of defaults.vim.  How about only resetting
'compatible' if it's set:

        " Use Vim settings, rather than Vi settings (much better!).
        " This must be first, because it changes other options as a side effect.
        " Avoid side effects when it was already reset.
        if &compatible
          set nocompatible
        endif


Any problem with that?


I launched Vim using:
gvim.exe -u vimrc_viminfo_location -U vimrc_viminfo_location test.txt


My vimrc_viminfo had the following:
        " Do not keep compatibility with Vi, use all of Vim's features
        set nocompatible
        set hlsearch
        " Do not use select mode, only use visual mode (see next option)
        set selectmode=
        " This option controls the behaviour of the buttons when selecting
        " text.  I dont like selectmode, since it is useless <g>.  Using
        " visual mode all the time when selecting text allows you to perform
        " a lot more functions over the selected range.
        " selectmode is really there to make Vim more like Windows.
        " This also forces the buttons on the mouse to perform like Unix, not
        " Windows
        behave xterm
        set cursorline
        set cursorcolumn
        set laststatus=2
        set shortmess=at
        set whichwrap=<,>,h,l
        set history=500
        set nobackup
        set nowritebackup
        set incsearch
        set showcmd
        set showbreak=>>
        set nostartofline
        set joinspaces
        set nrformats-=octal
        set ignorecase smartcase
        set virtualedit=
        set modelines=10
        set shiftwidth=4
        set nodigraph
        set esckeys
        set hidden
        set ruler
        set showmatch
        set visualbell
        set wildmenu
        set noerrorbells
        set autoindent
        set autochdir
        set foldopen+=jump
        set hidden
        set expandtab
        set tabstop=4

        syntax on
        filetype on
        filetype plugin on
        " VimInfo
        " \"50      - save only the first 50 lines of each register
        " '1000     - save 1000 local marks
        " h         - disable 'hlsearch' highlighting when starting
        " f1        - global marks are stored A - Z
        " rA:       - A: is a removable media, dont store stuff about it
        " r...:     - ...=directory, $TEMP: are temporary files, dont store stuff about it
        " :500      - lines of history
        " /500      - size of the search history
        " !         - save and restore global variables
        " n...      - viminfo file name and location
        set viminfo=\"50,'1000,h,f1,rA:,r$TEMP:,r$TMP:,r$TMPDIR:,:500,/500,!,n$VIM/_viminfo
        " Avoid command-line redraw on every entered character
        " by turning off Arabic shaping
        if has('arabic')
            set noarabicshape
        endif
        if has('linux')
            set fileformats=unix,dos,mac      " Leave files in Unix format first
        elseif has('macunix')
            set fileformats=mac,unix,dos      " Leave files in Mac format first
        else
            set fileformats=dos,unix,mac      " Leave files in DOS format first
        endif


And the resulting Vim had:

set viminfo?
  viminfo="50,'1000,h,f1,rA:,r$TEMP:,r$TMP:,r$TMPDIR:,:500,/500,!,n$VIM/_viminfo


So yes Bram, the change to defaults.vim from:
        set nocompatible

To:
        if &compatible
          set nocompatible
        endif


Would have prevented my issue.

Thanks,
David

--
--
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: