I have Vim 7 installed from my distro's package manager, and I compiled Vim 8 from source. Vim 8 is all in /usr/local. Then I created a new directory in $HOME called ".vim8". I have all my Vim 7 stuff in $HOME/.vim/, and I want a clean directory for Vim 8 in $HOME/.vim8/.

For Vim 8, I'm calling it like this: /usr/local/bin/vim8 -u "${HOME}/.vim8/vimrc".

That sets the vimrc to the right file. But it still doesn't load other things in ${HOME}/.vim8/. For example, I have the NERDTree plugin installed in pack:

$ tree -L 5 $HOME/.vim8/
├── pack
│   └── vendor
│       └── start
│           └── nerdtree
│               ├── autoload
│               ├── CHANGELOG.md
│               ├── doc
│               ├── lib
│               ├── LICENCE
│               ├── nerdtree_plugin
│               ├── plugin
│               ├── README.markdown
│               ├── screenshot.png
│               └── syntax
└── vimrc

Yet the plugin doesn't load. When I open vim8 I can't use NERDTree. It says it's not an editor command. Thinking about why this would be happening, I came up with a possibility: maybe it's using $HOME/.vim8/vimrc as the rc file, but it's not using $HOME/.vim8 for everything else. So I did this:

$ vim8 -u "${HOME}/.vim8/vimrc" -T dumb -c ':scriptnames|:q'

  1: ~/.vim8/vimrc
  2: /usr/local/share/vim/vim82/syntax/syntax.vim
  3: /usr/local/share/vim/vim82/syntax/synload.vim
  4: /usr/local/share/vim/vim82/syntax/syncolor.vim
  5: ~/.vim/filetype.vim
  6: /usr/local/share/vim/vim82/filetype.vim
     [ ...and a bunch of other files from local... ]

Aha! It appears I'm right. Vim is still looking in the .vim/ directory. So then I try setting runtimepath:

$ vim8 -u "${HOME}/.vim8/vimrc" --cmd ':set runtimepath=~/.vim8/,$VIMRUNTIME' -T dumb -c ':scriptnames|:q'

  1: ~/.vim8/vimrc
  2: /usr/local/share/vim/vim82/syntax/syntax.vim
  3: /usr/local/share/vim/vim82/syntax/synload.vim
  4: /usr/local/share/vim/vim82/syntax/syncolor.vim
  5: /usr/local/share/vim/vim82/filetype.vim
     [ ...and a bunch of other files from local... ]

And now it's not loading anything from .vim/. That's good. But also still not loading anything from .vim8/. NERDTree is still not available.

How do I tell Vim to use an alternate user directory for runtime files? I want to keep the 7 and 8 configuration separate and side-by-side. Is there anything I can do make Vim 8 use $HOME/.vim8/?

2 Answers 2


The specific path you're using (pack/vendor/start/nerdtree) is using the "packages" feature, which is a new Vim 8 feature that automates manipulation of 'runtimepath' in a way similar to how plug-in managers have been implemented.

That's why your attempt setting 'runtimepath' from --cmd doesn't work, since packages actually use a separate 'packpath' setting.

The location of ~/.vim is only set in Vim as part of those two options: 'runtimepath' and 'packpath'.

So you can override that to ~/.vim8 by simply resetting these two options in the .vimrc you use with Vim 8:

set runtimepath=~/.vim8,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim8/after
set packpath=~/.vim8,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim8/after

This should be enough to have Vim read files from the separate directory.

If you're building Vim 8 from sources, you might also want to consider patching it so it defaults to looking at ~/.vim8 rather than ~/.vim.

You can change those default paths in src/os_unix.h.

While at it, you might want to consider changing the location of the vimrc file and also the second vimrc file which is typically under ~/.vim, so you might want to update that one.

Please note that some plug-ins (in particular, plug-in managers) might use ~/.vim as their default as well (or even hardcode that path), so you might need to deal with those separately.

For example, Vundle defaults to using ~/.vim/bundle, but you can easily override that in the vundle#begin() call by passing a directory as an argument. (vim-plug, a more modern plug-in manager and in a way successor to Vundle, doesn't have this problem and will use the first path in 'runtimepath' instead as its default.)

Also consider whether you really want and need to keep separate ~/.vim directories for Vim 7 and Vim 8. Vim has enough features that should make it possible/easy to keep a single config that works in multiple versions.

For example, with Vim 8 packages, you can use a check such as if has('packages') to check whether the feature is enabled or not. If support for packages is not available, you can use vim-pathogen to load the plug-ins from the package directories, so you can have selective backwards compatibility for those too.

  • This is a very complete answer -- especially for pointing out where in the source the vimrc default is set! -- and very well written. Thank you. I do want to keep separate .vim directories because I want to test out Vim 8 with a clean config. I really like @Matt 's suggestion (in another answer) of putting that switch in the main/usual vimrc. Jan 2, 2020 at 18:02
  • What Is vim-pathogen the difference between vim-pathogen and vim-plug? I should use the latter one? I'm new to Vim. Jan 3, 2021 at 16:59
  • @Niing Yes, use vim-plug, it makes it very easy to manage plug-ins and it's pretty friendly to beginners. Pathogen is very similar to what Vim packages in Vim 8 do, and that depends on you fetching and updating the plug-ins yourself. vim-plug makes that easier, since it will install and update them for you.
    – filbranden
    Jan 3, 2021 at 17:06

Starting from Patch 7.4.1384 Vim has 'packpath' option for searching plugins. By default 'packpath' is equal to 'runtimepath' (until 'runtimepath' finally gets inflated by the plugins loaded), so you must keep them sync in your vimrc.

For Vim 8, I'm calling it like this: /usr/local/bin/vim8 -u "${HOME}/.vim8/vimrc".

You can add the following lines on top of your "main" vimrc instead:

" check if we have version-specific config
let s:dotvim = '~/.vim' . (v:version / 100)
if isdirectory(expand(s:dotvim))
    " setup runtimepath and packpath
    set runtimepath=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
    execute 'set runtimepath^=' . s:dotvim
    execute 'set runtimepath+=' . s:dotvim . '/after'
    if exists('&packpath')
        let &packpath = &runtimepath
    " proceed with special config
    execute 'source' s:dotvim . '/vimrc'
" default stuff (if any) follows...

Now an appropriate configuration will be chosen automatically.


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.