8

According to h: help:

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

I know I can set the number of lines higher, yet is there an "endless" option that always adds the command to the history unless disk space runs out?

1 Answer 1

11

No, it is not possible. According to :help 'history' you can have 10 thousand entries:

'history' 'hi'      number  (Vim default: 50, Vi default: 0)
            global
            {not in Vi}
    A history of ":" commands, and a history of previous search patterns
    is remembered.  This option decides how many entries may be stored in
    each of these histories (see |cmdline-editing|).
    The maximum value is 10000.

But this number should be more than enough. If you have complex commands which are hard to remember you should create commands on your vimrc (which you should include in your backups), instead of relaying in the command history, which usually you don't save in backups and can be corrupted/erased by some plugins.

With good (and short) commands/abbreviations/mappings you could easily type what you need, instead of keep searching the command history.

5
  • 1
    Yeah, I tend to use my vim (and bash) history as a repository of little one-liners, which works fine until something wipes them out, then I panic because I no longer know how to do anything. :-) So anything from my vim history I find myself using in multiples files and/or across editing sessions, I make them into commands. This also lets me name them and remember or look them up by name instead of trying to remember a unique prefix then doing a bunch of up arrows, and I can include comments with tricky ones to remind me how they work or what they're for.
    – blm
    Commented Dec 20, 2015 at 22:23
  • 3
    Now apply the same rule to bash and define aliases for those one-liners ;)
    – Vitor
    Commented Dec 21, 2015 at 20:37
  • Check this.. stackoverflow.com/a/8932857/4752883. I am having the same problem. I do write down complex commands into another file, but if the history worked repeatably I wouldnt have to manually copy paste these commands. Afterall the goal of computers is to automate stuff, and the history serves to not have to do this manually.One alternative is to alias vim such that it commits the current viminfo/other history files/config file to a git repository at regularly at startup or at certain periods of time
    – alpha_989
    Commented Dec 26, 2017 at 23:24
  • . Not sure why I keep loosing the vim history.. all other history files seem to be preserved.
    – alpha_989
    Commented Dec 26, 2017 at 23:24
  • what an arbitrary limit
    – CervEd
    Commented Aug 25, 2022 at 8:12

Your Answer

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

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