Is there a way to reference (or "source") another user's .vimrc file?
When I kuu
(a variant of su
that uses kerberos security tokens) to an admin user ID, I would like to use my personal .vimrc
file.
I don't want to overwrite the admin's existing .vimrc
file because the admin ID is shared by multiple users.
Some distributions might add an extension to configuration (e.g. in $VIM/vimfiles
) that source the file pointed by $MYVIMRC
, if this environmental variable was set beforehand (normally, it's set by Vim internally after reading vimrc). This way, you won't have to pass -u
each time you fire up vim. (You can of course do an alias instead, but that won't help with e.g., vipw
)
Keep in mind that .vimrc
can execute arbitrary commands, if you use /home/user/.vimrc
you may be creating a security issue (e.g., someone manages to compromise your user account, changes your .vimrc, and then gets root the next time you edit a file as root). You can, of course, keep a known-safe copy in ~root/
somewhere.
You could presumably even set something up in ~root/.bashrc
to automatically set MYVIMRC
to something different for each different administrator.
But again, keep in mind that is not regular Vim behaviour nor a very common practice. Better check documentation (:h initialization
and :h VIMINIT
) to learn about more "sanctioned" ways of changing the location of vimrc file.