Two different vim configs for one user based on alias

vimvimrc

I'm trying to get two different vim setups to load based on who is using it.

Problem

  • two users use the 'root' user regularly
  • each of us prefers different setup in vim.
    • He uses a simple .exrc file
    • I have a much more complicated .vimrc that uses pathogen#infect and loads a bunch of plugins.

Goal

I'd like to set something up so that if we type vi somefile it loads his config and vim somefile loads my config.

Solution

???

I've experimented with an alias for vim that loads the .vimrc from my user's home directory but then it throws an error trying to load the plugins, etc.
It's like it still expects the plugins to be in the root user's home directory instead of where the .vimrc was loaded from?

Looking for guidance on the best way to set this up.

Best Answer

Each of you can store your config files in different directories.

/home/user1/.vimrc

/home/user2/.vimrc

Then make an alias in roots ~/.bashrc to use the different configs.

alias vi='vim -u  /home/user1/.vimrc'
alias vim='vim -u /home/user2/.vimrc'

If you're having issues loading the plugins, make sure that your references in your .vimrc files don't use $HOME or ~/ to reference any files because when root tries to read them it will look in /root/path/to/file