Toggle between two different vim configurations

vim

I've got a .vimrc and .vim folder I've been tweaking for a while, but on my machine at a new job, I've just installed ryanb's dotfiles (which contains config files for vim, git, and more). There are things I like in each config, so ultimately I want to combine them into a new personal config. Meanwhile, I'd like to be able to switch back and forth.

Is there an easy command for this in vim – "use the following .vimrc and .vim directory" – or would it be more straightforward to swap out the files themselves when I want to switch?

Best Answer

The -u option will allow you to specify a configuration file other than ~/.vimrc, but there is no option to specify an alternative to the ~/.vim directory. However, you can have Vim use a different directory by modifying the 'runtimepath' ('rtp') option in each of your configuration files. For example, you could use this command

let &rtp = substitute(&rtp, '\.vim\>', '.vim1', 'g')

in one of your configuration files to tell Vim to use the ~/.vim1 directory rather than the ~/.vim directory.

Related Question