I actually have the following situation and thats what working actually:
Imagine you have to work as root on a file but you want ur own .vimrc without calling "-u". So I started the following "plugin":
let g:realuser=system('w | grep $(ps w | grep ' . getpid() . ' | head -n1 | awk "{ print \$2 }") | awk "{ print \$1 }"')
if $USER == 'root'
let g:vimrc=system('printf /home/%s/.vimrc '. g:realuser)
if filereadable(g:vimrc)
exec ":source " . g:vimrc
finish
endif
endif
I call it "realuser.vim" and "source" it in the root's .vimrc (/root/.vimrc).
If you login to your server now via SSH or on ubuntu via Gnome, you go "su -" and login as root. Then u change to your working directory and open the file. The script detects, that the real user who logged on to the machine is "yourlogin". Then it checks if in /home/yourlogin/ a file ".vimrc" is existent. So, it is and it loads it.
My problem is, that in /home/yourlogin/.vimrc is the following line:
source ~/.vim/plugin/someplugin.vim
So guess what. The /root/.vimrc loads the /home/yourlogin/.vimrc and therefore checks in /root/.vim/plugin/someplugin.vim which is not existent since it is only in /home/yourlogin/.vim
How can I use relative paths or sth like that to tell vim that the source file is only in /home/yourlogin/.vim/?