Use another user's .vimrc and .vim/

It seems that VIMINIT and VIMRUNTIME are not used as akira said.

VIMINIT is used as an Ex command, so VIMINIT=/home/user/.vimrc would try a search and give an errror like:

search hit BOTTOM, continuing at TOP
Error detected while processing VIMINIT:
E486: Pattern not found: home

VIMRUNTIME normally point to the location where vim's basic support files is installed, like /usr/share/vim/vim73, so if it's redirected to /home/user/.vim, vim would lost many basic functions unless your vim is just installed to /home/usr/.vim.


According to :help -u and :help vimrc, -u vimrc option can specify the .vimrc file but will skip most other initialization files, like system vimrc, eg. /etc/vimrc. If the specified vimrc file does almost all jobs, then the shortcomming, if called this, is trivial.

According to :help runtimepath, pathes of runtimepath will be searched for support files, so we can prepend /home/user/.vim and append /home/user/.vim/after to runtimepath before soucing vimrc file using --cmd options at startup.

To sum up, we can set up this alias to use ~/.vimrc and ~/vim:

alias vim='vim --cmd "set runtimepath^=/home/user/.vim" \
               --cmd "set runtimepath+=/home/user/.vim/after" \
               -u /home/user/.vimrc'

ps. Alternatively, two simple symbolic links may also work for you.

mv /root/.vimrc{,.bak}
mv /root/.vim{,.bak}
ln -s /home/user/.vimrc /root/
ln -s /home/user/.vim /root/

Probably the best solution ever.

export MYVIMRC="/xxx/.vimrc"
export VIMINIT=":set runtimepath+=/xxx/.vim|:source $MYVIMRC"

where xxx is the customized path.

Tags:

Linux

Vim

Root