Vim manual says: "The $MYVIMRC environment variable is set to the file that was first found, unless $MYVIMRC was already set and when using VIMINIT." Does this also mean that setting of $MYVIMRC (e.g. in the system vimrc) causes automatically its execution as private vimrc?

I tried the following in my system vimrc:

let $VIMFILES=$HOME."/Programs/Vim"
let $MYVIMRC=$VIMFILES."/vimrc"

but it didn't work. I had to add the line

let $VIMINIT="source ".$MYVIMRC

Of course, this worked. So my question is if I misunderstood the cited sentence from the manual or else what I have to do to make it work without the extra line.



  • No idea if this is the correct interpretation, but I always read that line simply to mean that the environment variable isn’t overwritten if it already exists, and that it doesn’t have any effect on the actual loading that takes place. – Rich May 5 '19 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.