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?
相关问题
- Emacs shell: save commit message
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- Hot reload on save
- Substituting zero-width match in vim script
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Vim: overloaded mapping for multiple modes
- How to use relative line numbering universally in
- How to copy the value of a vim option to a registe
- E185: Cannot find color scheme*
- How do I fix vim to properly indent folds containi
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
Mr. Baint has given the answer.
$HOME
directory.ls -l .viminfo
to check permissions.change permission so that group and owner also can have write permission. use:
It should fix the issue.
You will have to set the viminfo option. Set it in your $MYVIMRC
Update To find out where the option was last set/changed:
See http://vimdoc.sourceforge.net/htmldoc/starting.html#viminfo-file
You could also use
Session
files.You should check the permissions of the
.viminfo
file. You might need to change owner of the file to your current user usingchown
orsudo chown
.I went round in circles on this one a bit on Ubuntu and set viminfo solutions proposed above resulted in errors.
I eventually did the command "version" in the command mode and it came back with "-" for most stuff including: -cmdline_hist -cmdline_info
I ran the following command and it all worked fine again: sudo apt install vim