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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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