Re: $VIMRC over .vimrc ?

"D. Ben Knoble" <[email protected]> Wed, 18 Mar 2026 08:48:14 -0700 (PDT)
Newsgroups gmane.editors.vim
Message-ID <[email protected]>
------=_Part_24852_1142797456.1773848894895
Content-Type: multipart/alternative; 
	boundary="----=_Part_24853_2087405533.1773848894895"

------=_Part_24853_2087405533.1773848894895
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



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=20
doesn't exist in my case so it immediately goes to .vimrc. I'm reading the=
=20
documentation on how to create this $VIMRC file as so that it's read first,=
=20
rather then the .vimrc file ?


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

     c. Five places are searched for initializations.  The first that exist=
s
is used, the others are ignored.  The `$MYVIMRC` environment variable 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 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 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 be set=20
_by Vim_ to the file it finds.

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

--=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/b94=
a1e26-3185-4298-b3cf-46ecf054c720n%40googlegroups.com.

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

<br /><br /><div><div dir=3D"auto">On Tuesday, March 17, 2026 at 10:38:51=
=E2=80=AFAM UTC-4 Christopher wrote:<br /></div><blockquote style=3D"margin=
: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; bord=
er-left-color: rgb(204, 204, 204); padding-left: 1ex;">When initializing Vi=
m it searches first for $MYVIMRC, although that file doesn't exist in my ca=
se so it immediately goes to .vimrc. I'm reading the documentation on how t=
o create this $VIMRC file as so that it's read first, rather then the .vimr=
c file ?</blockquote><div><br /></div><div>I'm afraid your question isn't c=
lear to me, but let's look at `:help myvimrc`:</div><div><br /></div>=C2=A0=
 =C2=A0 =C2=A0c. Five places are searched for initializations. =C2=A0The fi=
rst that exists<br /><span style=3D"white-space: pre;">	</span>is used, the=
 others are ignored. =C2=A0The `$MYVIMRC` environment variable is<br /><spa=
n style=3D"white-space: pre;">	</span>set to the file that was first found,=
 unless `$MYVIMRC` was already set<br /><span style=3D"white-space: pre;">	=
</span>when using VIMINIT. =C2=A0The `$MYVIMDIR` environment variable is<br=
 /><span style=3D"white-space: pre;">	</span>set to the personal 'rtp' dire=
ctory, however it is not verified<br /><span style=3D"white-space: pre;">	<=
/span>that the directory actually exists.<br /><span style=3D"white-space: =
pre;">	</span>I =C2=A0 The environment variable VIMINIT (see also |compatib=
le-default|) (*)<br /><span style=3D"white-space: pre;">	</span>=C2=A0 =C2=
=A0 The value of $VIMINIT is used as an Ex command line.<br /><span style=
=3D"white-space: pre;">	</span>II =C2=A0The user vimrc file(s):<br /><span =
style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "$HOME/.vimrc"<span styl=
e=3D"white-space: pre;">		</span>=C2=A0 (for Unix) (*)<br /><span style=3D"=
white-space: pre;">		</span>=C2=A0 =C2=A0 "$HOME/.vim/vimrc"<span style=3D"=
white-space: pre;">		</span>=C2=A0 (for Unix) (*)<br /><span style=3D"white=
-space: pre;">		</span>=C2=A0 =C2=A0 "$XDG_CONFIG_HOME/vim/vimrc" =C2=A0(fo=
r Unix) (*)<br /><span style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "=
s:.vimrc"<span style=3D"white-space: pre;">			</span>=C2=A0 (for Amiga) (*)=
<br /><span style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "home:.vimrc=
"<span style=3D"white-space: pre;">		</span>=C2=A0 (for Amiga) (*)<br /><sp=
an style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "home:vimfiles:vimrc"=
<span style=3D"white-space: pre;">	</span>=C2=A0 (for Amiga) (*)<br /><span=
 style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "$VIM/.vimrc"<span styl=
e=3D"white-space: pre;">		</span>=C2=A0 (for Amiga) (*)<br /><span style=3D=
"white-space: pre;">		</span>=C2=A0 =C2=A0 "$HOME/_vimrc"<span style=3D"whi=
te-space: pre;">		</span>=C2=A0 (for Win32) (*)<br /><span style=3D"white-s=
pace: pre;">		</span>=C2=A0 =C2=A0 "$HOME/vimfiles/vimrc"<span style=3D"whi=
te-space: pre;">	</span>=C2=A0 (for Win32) (*)<br /><span style=3D"white-sp=
ace: pre;">		</span>=C2=A0 =C2=A0 "$VIM/_vimrc"<span style=3D"white-space: =
pre;">		</span>=C2=A0 (for Win32) (*)<br /><span style=3D"white-space: pre;=
">		</span>=C2=A0 =C2=A0 "$HOME/config/settings/vim/vimrc"<span style=3D"wh=
ite-space: pre;">	</span>(for Haiku) (*)<br /><br /><span style=3D"white-sp=
ace: pre;">		</span>Note: For Unix and Amiga, when ".vimrc" does not exist,=
<br /><span style=3D"white-space: pre;">		</span>"_vimrc" is also tried, in=
 case an MS-DOS compatible file<br /><span style=3D"white-space: pre;">		</=
span>system is used. =C2=A0For MS-Windows ".vimrc" is checked after<br /><s=
pan style=3D"white-space: pre;">		</span>"_vimrc", in case long file names =
are used.<br /><span style=3D"white-space: pre;">		</span>Note: For Win32, =
"$HOME" is checked first. =C2=A0If no "_vimrc" or<br /><span style=3D"white=
-space: pre;">		</span>".vimrc" is found there, "$VIM" is tried. =C2=A0See =
|$VIM| for when<br /><span style=3D"white-space: pre;">		</span>$VIM is not=
 set.<br /><span style=3D"white-space: pre;">	</span>III The environment va=
riable EXINIT.<br /><span style=3D"white-space: pre;">	</span>=C2=A0 =C2=A0=
 The value of $EXINIT is used as an Ex command line.<br /><span style=3D"wh=
ite-space: pre;">	</span>IV =C2=A0The user exrc file(s). =C2=A0Same as for =
the user vimrc file, but with<br /><span style=3D"white-space: pre;">	</spa=
n>=C2=A0 =C2=A0 "vimrc" replaced by "exrc". =C2=A0But only one of ".exrc" a=
nd "_exrc" is<br /><span style=3D"white-space: pre;">	</span>=C2=A0 =C2=A0 =
used, depending on the system. =C2=A0And without the (*)!<br /><span style=
=3D"white-space: pre;">	</span>V =C2=A0 The default vimrc file, $VIMRUNTIME=
/defaults.vim. =C2=A0This sets up<br /><span style=3D"white-space: pre;">	<=
/span>=C2=A0 =C2=A0 options values and has "syntax on" and "filetype on" co=
mmands,<br /><span style=3D"white-space: pre;">	</span>=C2=A0 =C2=A0 which =
is what most new users will want. =C2=A0See |defaults.vim|.<br /><div><br /=
></div><div>So, unless you use VIMINIT to set MYVIMRC, MYVIMRC is intended =
to be set _by Vim_ to the file it finds.</div><div><br /></div><div>Most fo=
lks I know use either ~/.vimrc or ~/.vim/vimrc (with equivalent ~/_vimrc or=
 ~/vimfiles/vimrc on Windows).=C2=A0</div></div>

<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/b94a1e26-3185-4298-b3cf-46ecf054c720n%40googlegroups.com?utm_medium=
=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/vim_use/b94=
a1e26-3185-4298-b3cf-46ecf054c720n%40googlegroups.com</a>.<br />

------=_Part_24853_2087405533.1773848894895--

------=_Part_24852_1142797456.1773848894895--