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 2


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. Commented Nov 29, 2017 at 0:20
  • @Carpetsmoker I don't use neovim but that's good to know thank you!
    – statox
    Commented Nov 29, 2017 at 8:31
  • Note, recent version of Vim also have the 'viminfofile' setting Commented 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


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.