简体   繁体   中英

How and where is my viminfo option set?

As far as I can tell I don't set viminfo anywhere, yet it is set.

:verbose set viminfo?

prints

  viminfo='100,<50,s10,h,rA:,rB:
    Last set from ~/vimfiles/vimrc

But ~/vimfiles/vimrc doesn't set it.

Even if I let ~/vimfiles/vimrc set it to an arbitrary value, viminfo will still be set to '100,<50,s10,h,rA:,rB: .

Why is that and how can I set/unset viminfo ?

You can set viminfo by temporary and permanent way:

  • For temporary way, you can input the setting command by :set viminfo=xxxx
  • For permanent way, you can input the setting in your ~/.vimrc in Linux and $VIM/_vimrc in Windows

My setting as below:

set viminfo=%,<800,'10,/50,:100,h,f0,n~/.vim/cache/.viminfo
"           | |    |   |   |    | |  + viminfo file path
"           | |    |   |   |    | + file marks 0-9,A-Z 0=NOT stored
"           | |    |   |   |    + disable 'hlsearch' loading viminfo
"           | |    |   |   + command-line history saved
"           | |    |   + search history saved
"           | |    + files marks saved
"           | + lines saved each register (old name for <, vi6.2)
"           + save/restore buffer list

And, the most important is set viminfo=xxx should come after set nocompatible

I had the same problem too. It turn out that the viminfo option is overwritten by the nocompatible flag. Since it overwrite other option too, it is better to place "set nocompatible" at very start of your vimrc file. This solved my issue with viminfo configuration.

That's the default value. :verbose is not really helpful, here, and that behaviour is not documented AFAIK but it always does that for default values.

I suggest you read :help 'viminfo' for the meaning of the values of the viminfo option and how to :set it (not :let ).

Please don't set these two variables: "<50,s10" if you don't fully understand what you are doing.

They are the maximum lines and maximum memory allowed, you will have great change to miss your data in the future with either of these two arguments set, without any warning!

Just leave them empty and default(no restrict).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM