3

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.

4

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
3
  • 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. 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 Nov 29 '17 at 11:22
1

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

1

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.