3

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.

2

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

  • Thanks, that did the trick. I also had to add "set nocompatible" to my vimrc before invoking pathogen#infect – Ryan Price Sep 27 '16 at 15:53
2

I know that it is not a direct answer for your question but ever considered creating your own root user? You can create a user with userid 0. It acts as a root account but it is your own user. You can have your vim settings, different shell, etc.

useradd -u 0 --non-unique yourroot

Of cource you should add other switches to create such account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.