Re: $VIMRC over .vimrc ?

Ben Knoble <[email protected]> Wed, 18 Mar 2026 15:48:19 -0400
Newsgroups gmane.editors.vim
Message-ID <[email protected]>
--Apple-Mail-3CC8B468-7DCB-4FB6-B181-9AF2447D3108
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


> Le 18 mars 2026 =C3=A0 14:33, Christopher <[email protected]> a =
=C3=A9crit :
>=20
> =EF=BB=BF
>=20
> On Wednesday, March 18, 2026 at 11:48:15=E2=80=AFAM UTC-4 D. Ben Knoble w=
rote:
> 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 ?
>=20
> I'm afraid your question isn't clear to me, but let's look at `:help myvi=
mrc`:
>=20
>      c. Five places are searched for initializations.  The first that exi=
sts
> 	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) (*)
>=20
> 		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|.
>=20
> So, unless you use VIMINIT to set MYVIMRC, MYVIMRC is intended to be set =
_by Vim_ to the file it finds.
>=20
> Most folks I know use either ~/.vimrc or ~/.vim/vimrc (with equivalent ~/=
_vimrc or ~/vimfiles/vimrc on Windows).=20
>=20
> I read the documentation, therefore like with many I also use the system =
wide .vimrc file when starting vim. I want to know how to set  the $MYVIMRC=
 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?). Th=
e per-user vimrc is more predictable to reason about. In a single-user envi=
ronment this may matter less, but still.

--=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/705=
49B20-8E72-4C91-B37A-C4564E9A67DF%40gmail.com.

--Apple-Mail-3CC8B468-7DCB-4FB6-B181-9AF2447D3108
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html class=3D"apple-mail-supports-explicit-dark-mode"><head><meta http-equ=
iv=3D"content-type" content=3D"text/html; charset=3Dutf-8"></head><body dir=
=3D"auto"><br id=3D"lineBreakAtBeginningOfSignature"><div dir=3D"ltr"><bloc=
kquote type=3D"cite">Le 18 mars 2026 =C3=A0 14:33, Christopher &lt;crestchr=
[email protected]&gt; a =C3=A9crit&nbsp;:<br><br></blockquote></div><block=
quote type=3D"cite"><div dir=3D"ltr">=EF=BB=BF<br><br><div><div dir=3D"auto=
">On Wednesday, March 18, 2026 at 11:48:15=E2=80=AFAM UTC-4 D. Ben Knoble w=
rote:<br></div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left:=
 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div dir=3D"auto">O=
n Tuesday, March 17, 2026 at 10:38:51=E2=80=AFAM UTC-4 Christopher wrote:<b=
r></div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px so=
lid rgb(204, 204, 204); padding-left: 1ex;">When initializing Vim it search=
es first for $MYVIMRC, although that file doesn't exist in my case so it im=
mediately goes to .vimrc. I'm reading the documentation on how to create th=
is $VIMRC file as so that it's read first, rather then the .vimrc file ?</b=
lockquote><div><br></div></div><div><div>I'm afraid your question isn't cle=
ar to me, but let's look at `:help myvimrc`:</div><div><br></div>&nbsp; &nb=
sp; &nbsp;c. Five places are searched for initializations. &nbsp;The first =
that exists<br><span style=3D"white-space: pre;">	</span>is used, the other=
s are ignored. &nbsp;The `$MYVIMRC` environment variable is<br><span 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>wh=
en using VIMINIT. &nbsp;The `$MYVIMDIR` environment variable is<br><span st=
yle=3D"white-space: pre;">	</span>set to the personal 'rtp' directory, howe=
ver it is not verified<br><span style=3D"white-space: pre;">	</span>that th=
e directory actually exists.<br><span style=3D"white-space: pre;">	</span>I=
 &nbsp; The environment variable VIMINIT (see also |compatible-default|) (*=
)<br><span style=3D"white-space: pre;">	</span>&nbsp; &nbsp; The value of $=
VIMINIT is used as an Ex command line.<br><span style=3D"white-space: pre;"=
>	</span>II &nbsp;The user vimrc file(s):<br><span style=3D"white-space: pr=
e;">		</span>&nbsp; &nbsp; "$HOME/.vimrc"<span style=3D"white-space: pre;">=
		</span>&nbsp; (for Unix) (*)<br><span style=3D"white-space: pre;">		</spa=
n>&nbsp; &nbsp; "$HOME/.vim/vimrc"<span style=3D"white-space: pre;">		</spa=
n>&nbsp; (for Unix) (*)<br><span style=3D"white-space: pre;">		</span>&nbsp=
; &nbsp; "$XDG_CONFIG_HOME/vim/vimrc" &nbsp;(for Unix) (*)<br><span style=
=3D"white-space: pre;">		</span>&nbsp; &nbsp; "s:.vimrc"<span style=3D"whit=
e-space: pre;">			</span>&nbsp; (for Amiga) (*)<br><span style=3D"white-spa=
ce: pre;">		</span>&nbsp; &nbsp; "home:.vimrc"<span style=3D"white-space: p=
re;">		</span>&nbsp; (for Amiga) (*)<br><span style=3D"white-space: pre;">	=
	</span>&nbsp; &nbsp; "home:vimfiles:vimrc"<span style=3D"white-space: pre;=
">	</span>&nbsp; (for Amiga) (*)<br><span style=3D"white-space: pre;">		</s=
pan>&nbsp; &nbsp; "$VIM/.vimrc"<span style=3D"white-space: pre;">		</span>&=
nbsp; (for Amiga) (*)<br><span style=3D"white-space: pre;">		</span>&nbsp; =
&nbsp; "$HOME/_vimrc"<span style=3D"white-space: pre;">		</span>&nbsp; (for=
 Win32) (*)<br><span style=3D"white-space: pre;">		</span>&nbsp; &nbsp; "$H=
OME/vimfiles/vimrc"<span style=3D"white-space: pre;">	</span>&nbsp; (for Wi=
n32) (*)<br><span style=3D"white-space: pre;">		</span>&nbsp; &nbsp; "$VIM/=
_vimrc"<span style=3D"white-space: pre;">		</span>&nbsp; (for Win32) (*)<br=
><span style=3D"white-space: pre;">		</span>&nbsp; &nbsp; "$HOME/config/set=
tings/vim/vimrc"<span style=3D"white-space: pre;">	</span>(for Haiku) (*)<b=
r><br><span style=3D"white-space: 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. &nbsp;For MS-Windows ".vimr=
c" is checked after<br><span 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. &nbsp;If no "_vimrc" or<br=
><span style=3D"white-space: pre;">		</span>".vimrc" is found there, "$VIM"=
 is tried. &nbsp;See |$VIM| for when<br><span style=3D"white-space: pre;">	=
	</span>$VIM is not set.<br><span style=3D"white-space: pre;">	</span>III T=
he environment variable EXINIT.<br><span style=3D"white-space: pre;">	</spa=
n>&nbsp; &nbsp; The value of $EXINIT is used as an Ex command line.<br><spa=
n style=3D"white-space: pre;">	</span>IV &nbsp;The user exrc file(s). &nbsp=
;Same as for the user vimrc file, but with<br><span style=3D"white-space: p=
re;">	</span>&nbsp; &nbsp; "vimrc" replaced by "exrc". &nbsp;But only one o=
f ".exrc" and "_exrc" is<br><span style=3D"white-space: pre;">	</span>&nbsp=
; &nbsp; used, depending on the system. &nbsp;And without the (*)!<br><span=
 style=3D"white-space: pre;">	</span>V &nbsp; The default vimrc file, $VIMR=
UNTIME/defaults.vim. &nbsp;This sets up<br><span style=3D"white-space: pre;=
">	</span>&nbsp; &nbsp; options values and has "syntax on" and "filetype on=
" commands,<br><span style=3D"white-space: pre;">	</span>&nbsp; &nbsp; whic=
h is what most new users will want. &nbsp;See |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 folks =
I know use either ~/.vimrc or ~/.vim/vimrc (with equivalent ~/_vimrc or ~/v=
imfiles/vimrc on Windows).&nbsp;</div></div></blockquote><div><br></div><di=
v>I read the documentation, therefore like with many I also use the system =
wide .vimrc file when starting vim. I want to know how to set&nbsp; the $MY=
VIMRC as the documentation ?&nbsp;</div></div>
</div></blockquote><br><div>Vim should set it automatically; =E2=80=9C:let =
$MYVIMRC=E2=80=9D should show the value, for example.&nbsp;</div><div><br><=
/div><div>I don=E2=80=99t recommend using the system-wide vimrc for anythin=
g beyond extremely niche use cases (maybe special hardware or software sett=
ings?). The per-user vimrc is more predictable to reason about. In a single=
-user environment this may matter less, but still.</div></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/70549B20-8E72-4C91-B37A-C4564E9A67DF%40gmail.com?utm_medium=3Demail=
&utm_source=3Dfooter">https://groups.google.com/d/msgid/vim_use/70549B20-8E=
72-4C91-B37A-C4564E9A67DF%40gmail.com</a>.<br />

--Apple-Mail-3CC8B468-7DCB-4FB6-B181-9AF2447D3108--