Linux – User-unique .vimrc file for servers as root user

linuxvim

I'm getting thrown into an IDE war at the office, where multiple users have root access on our servers, and like to have everything their own way with VIM. Unfortunately, we have our servers locked down enough to where if you want to do anything, you need to have root access. Obviously (although this is obviously frowned upon), we get tired of typing sudo before each command we type, which would require that we constantly type in our wonderfully complex passwords that are mandated on us over and over again, so naturally we all just execute the sudo su - command upon login to avoid all of this.

Of course, when it comes to VIM and custom .vimrc files, we are often times stepping on someone else's custom .vimrc file, and we have some whacked out functionality in these files that users have that may overwrite functionality that we have no idea about, much less have the patience to learn either.

When as root on a linux box, is there any way for all of us to still maintain our .vimrc file without having to overwrite the file over and over again every time someone wants to use VIM? Ideally, we have many virtual machines all with VIM installed, so a universal solution across all servers would be best, and we do have our Microsoft Windows user specific home directories mounted on the servers under /home/username.

Any recommendations for accommodating this?

Best Answer

I can think of 3 options. The first one is probably the simplest.

  1. call vim like the following vim -u /path/to/custom/.conifg fileToEdit
    Man Entry:

    -u {vimrc}  Use  the commands in the file {vimrc} for initializations. 
    

    All the other initial‐ izations are skipped. Use this to edit a special kind of files. It can also be used to skip all initializations by giving the name "NONE". See ":help initial‐ ization" within vim for more details.

      -U {gvimrc} Use the commands in the file {gvimrc} for GUI
    

    initializations. All the other GUI initializations are skipped. It can also be used to skip all GUI initializations by giving the name "NONE". See ":help gui-init" within vim for more details.

  2. sudo -i as was specified by @knittl https://stackoverflow.com/questions/6471592/user-unique-vimrc-file-for-servers-as-root-user/6471766#6471766

  3. lastly, https://stackoverflow.com/questions/1031396/how-to-share-one-vimrc-file-among-multiple-clients/1031624#1031624 which suggests keeping a set of personal config files in git or another version control system. Therefore each user could checkout what they need upon log in. Also, you can keep a history of your changes. version control is never a bad idea.
Related Question