Today, I decided to update my script and search for a way to easily change how I can load vimrc and .vim/ directory. And vim provides a very convenient way to do it using the environment variable.

  • VIMINIT - for switching vimrc.
  • VIMRUNTIME - for the .vim directory.

You can use it like this:

VIMINIT=/path/to/custom/vimrc vim

and

VIMRUNTIME=/path/to/.vim vim

You can combine them both as well.

Click here for the relevant docs