Re: $VIMRC over .vimrc ?

Eric Marceau <[email protected]> Wed, 18 Mar 2026 20:56:55 -0400
Newsgroups gmane.editors.vim
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------WG59mJrAbgjSTO79SpluC0yS
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: quoted-printable

I did a little experiment:

$ gvim dum

  * At this point, the file 'dum' was opened with my proper default,
    *~/.vim/vimrc*

$ MYVIMRC=3D*~/.vimrc.HOLD* ; export MYVIMRC
$ gvim dum

  * There are significant theme differences between the two files,
    but those differences were *not reflected* in the displayed theme.

$ MYVIMRC=3D"" ; export MYVIMRC
$ unset MYVIMRC
$ VIMRC=3D*~/.vimrc.HOLD* ; export VIMRC
$ gvim dum

  * Again, those differences were *not reflected* in the displayed theme.

So ... are those two variables actually being used anymore?



On 2026-03-18 19:32, Igbanam Ogbuluijah wrote:
> On Wed, Mar 18, 2026 at 03:48:19PM +0000, Ben Knoble wrote:
>>      Le 18 mars 2026 =C3=A0 14:33, Christopher<[email protected]=
m> a =C3=A9crit :
>>
>>
>>
>>
>>      On Wednesday, March 18, 2026 at 11:48:15=E2=80=AFAM UTC-4 D. Ben Kn=
oble wrote:
>>
>>          On Tuesday, March 17, 2026 at 10:38:51=E2=80=AFAM UTC-4 Christo=
pher wrote:
>>
>>              When initializing Vim it searches first for $MYVIMRC, altho=
ugh that
>>              file doesn't exist in my case so it immediately goes to .vi=
mrc. I'm
>>              reading the documentation on how to create this $VIMRC file=
 as so
>>              that it's read first, rather then the .vimrc file ?
>>
>>
>>          I'm afraid your question isn't clear to me, but let's look at `=
:help
>>          myvimrc`:
>>
>>               c. Five places are searched for initializations.  The firs=
t that
>>          exists
>>          is used, the others are ignored.  The `$MYVIMRC` environment va=
riable
>>          is
>>          set to the file that was first found, unless `$MYVIMRC` was alr=
eady set
>>          when using VIMINIT.  The `$MYVIMDIR` environment variable is
>>          set to the personal 'rtp' directory, however it is not verified
>>          that the directory actually exists.
>>          I   The environment variable VIMINIT (see also |compatible-defa=
ult|)
>>          (*)
>>              The value of $VIMINIT is used as an Ex command line.
>>          II  The user vimrc file(s):
>>              "$HOME/.vimrc"   (for Unix) (*)
>>              "$HOME/.vim/vimrc"   (for Unix) (*)
>>              "$XDG_CONFIG_HOME/vim/vimrc"  (for Unix) (*)
>>              "s:.vimrc"   (for Amiga) (*)
>>              "home:.vimrc"   (for Amiga) (*)
>>              "home:vimfiles:vimrc"   (for Amiga) (*)
>>              "$VIM/.vimrc"   (for Amiga) (*)
>>              "$HOME/_vimrc"   (for Win32) (*)
>>              "$HOME/vimfiles/vimrc"   (for Win32) (*)
>>              "$VIM/_vimrc"   (for Win32) (*)
>>              "$HOME/config/settings/vim/vimrc" (for Haiku) (*)
>>
>>          Note: For Unix and Amiga, when ".vimrc" does not exist,
>>          "_vimrc" is also tried, in case an MS-DOS compatible file
>>          system is used.  For MS-Windows ".vimrc" is checked after
>>          "_vimrc", in case long file names are used.
>>          Note: For Win32, "$HOME" is checked first.  If no "_vimrc" or
>>          ".vimrc" is found there, "$VIM" is tried.  See |$VIM| for when
>>          $VIM is not set.
>>          III The environment variable EXINIT.
>>              The value of $EXINIT is used as an Ex command line.
>>          IV  The user exrc file(s).  Same as for the user vimrc file, bu=
t with
>>              "vimrc" replaced by "exrc".  But only one of ".exrc" and "_=
exrc" is
>>              used, depending on the system.  And without the (*)!
>>          V   The default vimrc file, $VIMRUNTIME/defaults.vim.  This set=
s up
>>              options values and has "syntax on" and "filetype on" comman=
ds,
>>              which is what most new users will want.  See |defaults.vim|=
.
>>
>>          So, unless you use VIMINIT to set MYVIMRC, MYVIMRC is intended =
to be
>>          set _by Vim_ to the file it finds.
>>
>>          Most folks I know use either ~/.vimrc or ~/.vim/vimrc (with equ=
ivalent
>>          ~/_vimrc or ~/vimfiles/vimrc on Windows).
>>
>>
>>      I read the documentation, therefore like with many I also use the s=
ystem
>>      wide .vimrc file when starting vim. I want to know how to set  the =
$MYVIMRC
>>      as the documentation ?
>>
>>
>> Vim should set it automatically; =E2=80=9C:let $MYVIMRC=E2=80=9D should =
show the value, for
>> example.
>>
>> I don=E2=80=99t recommend using the system-wide vimrc for anything beyon=
d extremely
>> niche use cases (maybe special hardware or software settings?). The per-=
user
>> vimrc is more predictable to reason about. In a single-user environment =
this
>> may matter less, but still.
>>
>> --
>> --
>> You received this message from the "vim_use" maillist.
>> Do not top-post! Type your reply below the text you are replying to.
>> For more information, visithttp://www.vim.org/maillist.php
>>
>> ---
>> You received this message because you are subscribed to the Google Group=
s
>> "vim_use" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n email
>> [email protected].
>> To view this discussion visithttps://groups.google.com/d/msgid/vim_use/
>> 70549B20-8E72-4C91-B37A-C4564E9A67DF%40gmail.com.
> Hold on=E2=80=A6 the OP may have a point here.
>
> The documentation does say something about environment variables; but I
> think we are jumping into some user-global VIMRC because, quite frankly,
> that's the cultural way of going this. But=E2=80=A6!
>
> The documentation does say there's an environment variable `VIMINIT`
> which can be set as an Ex command, and this would be the first place Vim
> looks to for initialization configuration. Now, the way I got this to
> work is
>
>      VIMINIT=3D"set number relativenumber" vim
>
> I did this on a blank install of vim. Without the VIMINIT variable set,
> there are no numbers.
>
> So if you're looking to set an environment variable Vim respects on
> initialization, this is it. That said, the amount of customizations
> going into Vim these days is way too much for an environment variable;
> plus=E2=80=A6 if you want to use the environment variable to source some =
file,
> you might as well use a VIMRC, and use the `runtime` command for multipe
> files. I think this is the reason the community has culturally favoured
> the VIMRC route for customizations.
>
> Just thought to call this out since the OP was specific about an
> environment variable.
>
>
> ~ Igbanam
>

--=20
--=20
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---=20
You received this message because you are subscribed to the Google Groups "=
vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_use/853=
7951d-3da7-4cd3-8652-643516cf77f0%40gmail.com.

--------------WG59mJrAbgjSTO79SpluC0yS
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8=
">
  </head>
  <body>
    <p>I did a little experiment:</p>
    <p>$ gvim dum</p>
    <ul>
      <li>At this point, the file 'dum' was opened with my proper
        default,<br>
        <b>~/.vim/vimrc</b><br>
      </li>
    </ul>
    <p>$ MYVIMRC=3D<b>~/.vimrc.HOLD</b> ; export MYVIMRC<br>
      $ gvim dum<br>
    </p>
    <ul>
      <li>There are significant theme differences between the two files,<br=
>
        but those differences were <b>not reflected</b> in the
        displayed theme.<br>
      </li>
    </ul>
    <p>$ MYVIMRC=3D"" ; export MYVIMRC<br>
      $ unset MYVIMRC<br>
      $ VIMRC=3D<b>~/.vimrc.HOLD</b> ; export VIMRC<br>
      $ gvim dum<br>
    </p>
    <ul>
      <li>Again, those differences were <b>not reflected</b> in the
        displayed theme.<br>
      </li>
    </ul>
    <p>So ... are those two variables actually being used anymore?<br>
    </p>
    <p><br>
      <br>
    </p>
    <div class=3D"moz-cite-prefix">On 2026-03-18 19:32, Igbanam Ogbuluijah
      wrote:<br>
    </div>
    <blockquote type=3D"cite" cite=3D"mid:[email protected]">
      <pre wrap=3D"" class=3D"moz-quote-pre">On Wed, Mar 18, 2026 at 03:48:=
19PM +0000, Ben Knoble wrote:
</pre>
      <blockquote type=3D"cite">
        <pre wrap=3D"" class=3D"moz-quote-pre">
    Le 18 mars 2026 =C3=A0 14:33, Christopher <a class=3D"moz-txt-link-rfc2=
396E" href=3D"mailto:[email protected]">&lt;crestchristopher@gmail=
.com&gt;</a> a =C3=A9crit :




    On Wednesday, March 18, 2026 at 11:48:15=E2=80=AFAM UTC-4 D. Ben Knoble=
 wrote:

        On Tuesday, March 17, 2026 at 10:38:51=E2=80=AFAM UTC-4 Christopher=
 wrote:

            When initializing Vim it searches first for $MYVIMRC, although =
that
            file doesn't exist in my case so it immediately goes to .vimrc.=
 I'm
            reading the documentation on how to create this $VIMRC file as =
so
            that it's read first, rather then the .vimrc file ?


        I'm afraid your question isn't clear to me, but let's look at `:hel=
p
        myvimrc`:

             c. Five places are searched for initializations.  The first th=
at
        exists
        is used, the others are ignored.  The `$MYVIMRC` environment variab=
le
        is
        set to the file that was first found, unless `$MYVIMRC` was already=
 set
        when using VIMINIT.  The `$MYVIMDIR` environment variable is
        set to the personal 'rtp' directory, however it is not verified
        that the directory actually exists.
        I   The environment variable VIMINIT (see also |compatible-default|=
)
        (*)
            The value of $VIMINIT is used as an Ex command line.
        II  The user vimrc file(s):
            "$HOME/.vimrc"   (for Unix) (*)
            "$HOME/.vim/vimrc"   (for Unix) (*)
            "$XDG_CONFIG_HOME/vim/vimrc"  (for Unix) (*)
            "s:.vimrc"   (for Amiga) (*)
            "home:.vimrc"   (for Amiga) (*)
            "home:vimfiles:vimrc"   (for Amiga) (*)
            "$VIM/.vimrc"   (for Amiga) (*)
            "$HOME/_vimrc"   (for Win32) (*)
            "$HOME/vimfiles/vimrc"   (for Win32) (*)
            "$VIM/_vimrc"   (for Win32) (*)
            "$HOME/config/settings/vim/vimrc" (for Haiku) (*)

        Note: For Unix and Amiga, when ".vimrc" does not exist,
        "_vimrc" is also tried, in case an MS-DOS compatible file
        system is used.  For MS-Windows ".vimrc" is checked after
        "_vimrc", in case long file names are used.
        Note: For Win32, "$HOME" is checked first.  If no "_vimrc" or
        ".vimrc" is found there, "$VIM" is tried.  See |$VIM| for when
        $VIM is not set.
        III The environment variable EXINIT.
            The value of $EXINIT is used as an Ex command line.
        IV  The user exrc file(s).  Same as for the user vimrc file, but wi=
th
            "vimrc" replaced by "exrc".  But only one of ".exrc" and "_exrc=
" is
            used, depending on the system.  And without the (*)!
        V   The default vimrc file, $VIMRUNTIME/defaults.vim.  This sets up
            options values and has "syntax on" and "filetype on" commands,
            which is what most new users will want.  See |defaults.vim|.

        So, unless you use VIMINIT to set MYVIMRC, MYVIMRC is intended to b=
e
        set _by Vim_ to the file it finds.

        Most folks I know use either ~/.vimrc or ~/.vim/vimrc (with equival=
ent
        ~/_vimrc or ~/vimfiles/vimrc on Windows).=20


    I read the documentation, therefore like with many I also use the syste=
m
    wide .vimrc file when starting vim. I want to know how to set  the $MYV=
IMRC
    as the documentation ?=20


Vim should set it automatically; =E2=80=9C:let $MYVIMRC=E2=80=9D should sho=
w the value, for
example.=20

I don=E2=80=99t recommend using the system-wide vimrc for anything beyond e=
xtremely
niche use cases (maybe special hardware or software settings?). The per-use=
r
vimrc is more predictable to reason about. In a single-user environment thi=
s
may matter less, but still.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit <a class=3D"moz-txt-link-freetext" href=3D"http=
://www.vim.org/maillist.php">http://www.vim.org/maillist.php</a>

---
You received this message because you are subscribed to the Google Groups
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail
to <a class=3D"moz-txt-link-abbreviated" href=3D"mailto:vim_use+unsubscribe=
@googlegroups.com">[email protected]</a>.
To view this discussion visit <a class=3D"moz-txt-link-freetext" href=3D"ht=
tps://groups.google.com/d/msgid/vim_use/">https://groups.google.com/d/msgid=
/vim_use/</a>
70549B20-8E72-4C91-B37A-C4564E9A67DF%40gmail.com.
</pre>
      </blockquote>
      <pre wrap=3D"" class=3D"moz-quote-pre">
Hold on=E2=80=A6 the OP may have a point here.

The documentation does say something about environment variables; but I
think we are jumping into some user-global VIMRC because, quite frankly,
that's the cultural way of going this. But=E2=80=A6!

The documentation does say there's an environment variable `VIMINIT`
which can be set as an Ex command, and this would be the first place Vim
looks to for initialization configuration. Now, the way I got this to
work is

    VIMINIT=3D"set number relativenumber" vim

I did this on a blank install of vim. Without the VIMINIT variable set,
there are no numbers.

So if you're looking to set an environment variable Vim respects on
initialization, this is it. That said, the amount of customizations
going into Vim these days is way too much for an environment variable;
plus=E2=80=A6 if you want to use the environment variable to source some fi=
le,
you might as well use a VIMRC, and use the `runtime` command for multipe
files. I think this is the reason the community has culturally favoured
the VIMRC route for customizations.

Just thought to call this out since the OP was specific about an
environment variable.


~ Igbanam

</pre>
    </blockquote>
  </body>
</html>

<p></p>

-- <br />
-- <br />
You received this message from the &quot;vim_use&quot; maillist.<br />
Do not top-post! Type your reply below the text you are replying to.<br />
For more information, visit <a href=3D"http://www.vim.org/maillist.php">htt=
p://www.vim.org/maillist.php</a><br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;vim_use&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">vim_use+uns=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
vim_use/8537951d-3da7-4cd3-8652-643516cf77f0%40gmail.com?utm_medium=3Demail=
&utm_source=3Dfooter">https://groups.google.com/d/msgid/vim_use/8537951d-3d=
a7-4cd3-8652-643516cf77f0%40gmail.com</a>.<br />

--------------WG59mJrAbgjSTO79SpluC0yS--