keflavich
keflavich

Reputation: 19205

What sets vim history?

I have had the command

set history=10000

in my .vimrc for a while, and realized that it wasn't setting the history -

:set history

prints 20.

I then moved set history=10000 to the end of my .vimrc and re-sourced it, and now history=10000 as requested.

There are no other instances of set history in my .vimrc. What other commands set the history length? Is it possible that function definitions override history? Are there other settings I should be worried about overriding?

Upvotes: 16

Views: 10227

Answers (2)

johnsyweb
johnsyweb

Reputation: 141780

Type:

:verbose set history

This will tell you from where 'history' was last set.

N.B: If it says:

  history=20
        Last set from ~/.vimrc

...and you don't have either set hi=20 or set history=20 in your .vimrc, you need to ensure that you have set history=10000 after set nocp, as highlighted by ZyX's answer. This is probably why you found that it worked when you moved this to the end of your initialisation file.

Upvotes: 25

ZyX
ZyX

Reputation: 53604

According to the help,

'history' 'hi' number (Vim default: 20, Vi default: 0)

NOTE: This option is set to the Vi default value when 'compatible' is set and to the Vim default value when 'compatible' is reset.

, so if you have set nocompatible somewhere in the vimrc (it is very common to have it), then set history must go after this statement. It is a generic rule: no matter what you write, it should go after set nocompatible. It must go after set nocompatible if it is an option. There are some things (including some options) that are safe to appear before it, but the only thing I use before this statement is a guard.

Upvotes: 21

Related Questions