According to this FAQ for moving .viminfo file to .vim dir we should add viminfo+=n~/.vim/viminfo to vimrc file but when I put this line in my vimrc, every time I open vim, it will return this: E492: Not an editor command: viminfo+=n~/.vim/viminfo But I don't know why and how can I fix it, so please let me know that and don't mark [duplicate] on this question.
2 Answers
viminfo is an option, @Tommy A forgot the keyword set in his command:
set viminfo+=n~/.vim/viminfo should work properly. If you read :h 'viminfo' you can see an example:
:set viminfo='50,<1000,s100,:0,n~/vim/viminfo Edit As @Carpetsmoker mentioned it in the comments, neovim has a different format for these options so one should use the following:
if has('nvim') | let &viminfo .= '.nvim' | endif - If you care about Vim/Neovim compatibility then you need to do something like:
if has('nvim') | let &viminfo .= '.nvim' | endif, as Neovim uses a different format.Martin Tournoij– Martin Tournoij2017-11-29 00:20:12 +00:00Commented Nov 29, 2017 at 0:20 - @Carpetsmoker I don't use neovim but that's good to know thank you!statox– statox2017-11-29 08:31:05 +00:00Commented Nov 29, 2017 at 8:31
- Note, recent version of Vim also have the 'viminfofile' settingChristian Brabandt– Christian Brabandt2017-11-29 11:22:01 +00:00Commented Nov 29, 2017 at 11:22
I know its quite a while now, but I am just mentioning this for future readers.
I was facing the same issue while trying to change the location for viminfo file in vimrc. At last setting the value of viminfofile option worked for me.
Added the following to my vimrc:
set viminfofile=D:\vim\viminfo It works for me on windows with vim 8.2
- Welcome to Vi and Vim!filbranden– filbranden2021-05-27 16:02:31 +00:00Commented May 27, 2021 at 16:02