15

I have already put the following setting in my .vimrc file:

set history=1000

It's been there for a while, I work in vim on a daily basis, so there have been many commands executed by now. I know from vim help, that duplicates and mapped command-lines are not stored, and it also says:

Use the 'history' option to set the number of lines that are remembered
(default: 20).

Currently there are around 130 lines in my history (:his and q: vary a little bit, second one has about 90 entries), but in my opinion there should be more. There are some commands missing, like opening certain files or some substitution commands with complex regex. There have not been used for a while, but I have this history size increased long enough.

Is there another limit, which I didn't know about? Or maybe it's not a correct way of increasing cmdline history size?

3 Answers 3

16

A : value in your 'viminfo' option may limit the number of persisted commands. See :help viminfo-::

: Maximum number of items in the command-line history to be
  saved.  When not included, the value of 'history' is used.
9
  • This might be it. How can I change this setting? :set viminfo=:1000 will do?
    – qiubix
    Apr 14, 2015 at 14:45
  • 2
    That would be a non-default value. Check with :verbose set viminfo? where this got set, and best change that location. As this option uses a set of values, it's best to use :set viminfo-=:42 | set viminfo+=:1000 to modify it. Apr 14, 2015 at 15:03
  • 1
    obviously I have to expand set of values using += instead of just overwriting it. Using verbose I got: Last set from ~/.vimrc after some default values. I don't have any setting changing viminfo behaviour, so I don't know what to change there. I'll just add this line with :1000 parameter and accept your answer when I notice increase in history size.
    – qiubix
    Apr 14, 2015 at 16:54
  • Could you expand on this answer a bit to show how to do this? Seems like :set viminfo+=:1000 would do it, but I'm not sure I follow exactly why you subtract 42 from it first. Nov 1, 2017 at 1:43
  • 1
    @TankorSmash: The 42 isn't subtracted; this intends to remove the :42 part (42 is just a random number, as the precise number in OP's config isn't known) from the 'viminfo' option. If you don't have an existing default in there, set viminfo+=:1000 will indeed be enough. Nov 2, 2017 at 10:35
0

The viminfo value seems to be a comma separated set of values.

In my case I changed:

:set viminfo=!,'10000,<50,s10,h

to

:set viminfo=!,'10000,<50,s10,h,:10000
1
  • +=/^= will handle the comma-separated stuff for you
    – D. Ben Knoble
    Sep 8, 2020 at 13:51
-2

Add this to your .vimrc:

if &history < 1000
  set history=1000
endif

Source: https://github.com/tpope/vim-sensible/commit/f7bdc45c03083d61c3955e54a2ef610b21d2801e

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.