Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that I can :source /path/to/some/.vimrc to load my user's .vimrc when running as root, but how can I use the entire .vim/ directory as well? Is there a startup option for using /home/user/.vim/ that I can set up as an alias?

And where in the fine manual would I have found this information if I had know what to look for. A simple :help .vim or :help .vimrc did not find the information regarding using the entire .vim/ direcotry (-U is only for the .vim file).


share|improve this question
:help vimruntime in this case. – Daniel Andersson Apr 18 '12 at 15:04
up vote 1 down vote accepted

use the environment variable VIMINIT to point to the right .vimrc and VIMRUNTIME to point to the right .vim-directory. you can do this via env:

$> env VIMINIT=/home/user/.vimrc VIMRUNTIME=/home/user/.vim/ vim

$> VIMINIT='let $MYVIMRC = expand('\''~user'\'') . '\''/.vimrc'\''|source $MYVIMRC' vim -c 'set runtimepath=~user/.vim,/var/lib/vim/addons,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/var/lib/vim/addons/after,~user/.vim/after'

as always: if thats too long to type, create a shell-function or a shell-alias.

to read more about how vim launches and what happens behind the scenes, read :help initialization.

share|improve this answer
Thank you akira! This is exactly what I need, and thank you for the man page reference. – dotancohen Apr 18 '12 at 15:55

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/
share|improve this answer
Thank you for the ideas. I'll look into them. – dotancohen Feb 25 '13 at 14:04
I've been searching for this solution for quite sometime and this is the most definitive answer I have come across. – Francis Mar 28 '14 at 16:34
Thank you for that answer, I had the exact problem you had with the E486 error. But your answer got me thinking : wouldn't it be possible to set VIMINIT=":source /home/user/.vimrc" and just be done with it? At least, it seems to work for me... – user43791 Feb 13 '15 at 22:22
Even better, you can modify the runtimepath as you indicated in the same command : VIMINIT=":set runtimepath^=/home/user.vim|:source /home/user/.vimrc". It works like a charm for me! :) – user43791 Feb 13 '15 at 22:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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