Vim record history

Vim stores the list of commands that we applied using : for the current execution. But when I close vim and start it again, the vim command history is lost. I tried set history = 1000 in the .vimrc file but that did not help.
Where does Vim maintain the local command history?
What is the command to retain command history?


Just an issue that caught me out the other day, which may or may not be your problem:

On some Linux systems (e.g. Ubuntu), if the very first time you run VIM, you run it as a super-user, then the $HOME/.viminfo file gets created with root owner and your local user does not have permissions to write to it. This explained why my VIM was not storing command history when it was all configured up correctly.

Bottom line: on a *nix system, locate your .viminfo file, and make sure you have read/write permissions on it.


To check whether Vim supports the 'viminfo' file (which stores the history), :echo has('viminfo'). The corresponding setting must not be empty: :set viminfo?, and :set history? should be greater than one.

If there's a problem writing the viminfo file (though Vim should complain in that case), you could try passing a different location via vim -i /tmp/viminfo