An easier way to do this than overriding the 'runtimepath'
setting in your vimrc is to set the HOME
environment variable for the vim command in your shell command. e.g.
In bash:
mkdir ~/new-vimhome
HOME=~/new-vimhome vim
Or in the Windows Command prompt:
mkdir %USERDRIVE%%USERPATH%\new-vimhome
set HOME=%USERDRIVE%%USERPATH%\new-vimhome
vim
(Note that Windows Vim uses the HOME
environment variable if it is set, but it usually isn't — and other programs won't generally check it — so it should be safe to set it persistently as we do above.)
You can then set up any Vim configuration you desire within that home directory, in the usual way. e.g.:
Bash:
mkdir ~/new-vimhome/.vim
touch ~/new-vimhome/.vimrc
Windows Command Prompt:
mkdir %USERDRIVE%%USERPATH%\new-vimhome\vimfiles
vim %USERDRIVE%%USERPATH%\new-vimhome\_vimrc
N.B. As @eckes notes in a comment, this solution does have the caveat that $HOME
will point to the new directory rather than your real home directory, so the $HOME
environment variable and ~
shortcut can't be used for accessing files located there within an instance Vim running in this way. (Although you can of course still access such files using absolute paths or Windows's standard environment variables.) If you don't want this degree of separation from your usual environment, their solution might therefore be preferable.