Re: $VIMRC over .vimrc ?

Christopher <[email protected]> Thu, 19 Mar 2026 00:56:08 -0700 (PDT)
Newsgroups gmane.editors.vim
Message-ID <[email protected]>
------=_Part_52884_1154490626.1773906968364
Content-Type: multipart/alternative; 
	boundary="----=_Part_52885_1321359255.1773906968364"

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



On Wednesday, March 18, 2026 at 3:48:41=E2=80=AFPM UTC-4 Ben Knoble wrote:


Le 18 mars 2026 =C3=A0 14:33, Christopher <[email protected]> a =C3=A9c=
rit :

=EF=BB=BF



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

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


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


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

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


In my case running the command ":let $MYVIMRC" returns a invalid=20
expression. =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/92e=
993d6-8baf-4b42-bfee-c7eab4962f9bn%40googlegroups.com.

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

<br /><br /><div><div dir=3D"auto">On Wednesday, March 18, 2026 at 3:48:41=
=E2=80=AFPM UTC-4 Ben Knoble wrote:<br /></div><blockquote style=3D"margin:=
 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left=
: 1ex;"><div dir=3D"auto"><br /><div dir=3D"ltr"><blockquote type=3D"cite">=
Le 18 mars 2026 =C3=A0 14:33, Christopher &lt;<a href=3D"" rel=3D"nofollow"=
>[email protected]</a>&gt; a =C3=A9crit=C2=A0:<br /><br /></blockquote>=
</div><blockquote type=3D"cite"><div dir=3D"ltr">=EF=BB=BF</div></blockquot=
e></div><div dir=3D"auto"><blockquote type=3D"cite"><div dir=3D"ltr"><br />=
<br /><div><div dir=3D"auto">On Wednesday, March 18, 2026 at 11:48:15=E2=80=
=AFAM UTC-4 D. Ben Knoble wrote:<br /></div><blockquote style=3D"margin: 0p=
x 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1=
ex;"><div><div dir=3D"auto">On Tuesday, March 17, 2026 at 10:38:51=E2=80=AF=
AM UTC-4 Christopher wrote:<br /></div><blockquote style=3D"margin: 0px 0px=
 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">=
When initializing Vim it searches first for $MYVIMRC, although that file do=
esn't exist in my case so it immediately goes to .vimrc. I'm reading the do=
cumentation on how to create this $VIMRC file as so that it's read first, r=
ather then the .vimrc file ?</blockquote><div><br /></div></div><div><div>I=
'm afraid your question isn't clear to me, but let's look at `:help myvimrc=
`:</div><div><br /></div>=C2=A0 =C2=A0 =C2=A0c. Five places are searched fo=
r initializations. =C2=A0The first that exists<br /><span style=3D"white-sp=
ace: pre;">	</span>is used, the others are ignored. =C2=A0The `$MYVIMRC` en=
vironment variable is<br /><span style=3D"white-space: pre;">	</span>set to=
 the file that was first found, unless `$MYVIMRC` was already set<br /><spa=
n style=3D"white-space: pre;">	</span>when using VIMINIT. =C2=A0The `$MYVIM=
DIR` environment variable is<br /><span style=3D"white-space: pre;">	</span=
>set to the personal 'rtp' directory, 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 varia=
ble VIMINIT (see also |compatible-default|) (*)<br /><span style=3D"white-s=
pace: pre;">	</span>=C2=A0 =C2=A0 The value of $VIMINIT is used as an Ex co=
mmand line.<br /><span style=3D"white-space: pre;">	</span>II =C2=A0The use=
r vimrc file(s):<br /><span style=3D"white-space: pre;">		</span>=C2=A0 =C2=
=A0 "$HOME/.vimrc"<span style=3D"white-space: pre;">		</span>=C2=A0 (for Un=
ix) (*)<br /><span style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "$HOM=
E/.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_CONF=
IG_HOME/vim/vimrc" =C2=A0(for Unix) (*)<br /><span style=3D"white-space: pr=
e;">		</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;">		</spa=
n>=C2=A0 =C2=A0 "home:.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: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 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 Win32) (=
*)<br /><span style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "$HOME/vim=
files/vimrc"<span style=3D"white-space: pre;">	</span>=C2=A0 (for Win32) (*=
)<br /><span style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "$VIM/_vimr=
c"<span style=3D"white-space: pre;">		</span>=C2=A0 (for Win32) (*)<br /><s=
pan style=3D"white-space: pre;">		</span>=C2=A0 =C2=A0 "$HOME/config/settin=
gs/vim/vimrc"<span style=3D"white-space: pre;">	</span>(for Haiku) (*)<br /=
><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;">		</s=
pan>"_vimrc" is also tried, in case an MS-DOS compatible file<br /><span st=
yle=3D"white-space: pre;">		</span>system is used. =C2=A0For MS-Windows ".v=
imrc" is checked after<br /><span style=3D"white-space: pre;">		</span>"_vi=
mrc", in case long file names are used.<br /><span style=3D"white-space: pr=
e;">		</span>Note: For Win32, "$HOME" is checked first. =C2=A0If no "_vimrc=
" or<br /><span style=3D"white-space: pre;">		</span>".vimrc" is found ther=
e, "$VIM" is tried. =C2=A0See |$VIM| for when<br /><span style=3D"white-spa=
ce: pre;">		</span>$VIM is not set.<br /><span style=3D"white-space: pre;">=
	</span>III The environment variable EXINIT.<br /><span style=3D"white-spac=
e: pre;">	</span>=C2=A0 =C2=A0 The value of $EXINIT is used as an Ex comman=
d line.<br /><span style=3D"white-space: pre;">	</span>IV =C2=A0The user ex=
rc file(s). =C2=A0Same as for the user vimrc file, but with<br /><span styl=
e=3D"white-space: pre;">	</span>=C2=A0 =C2=A0 "vimrc" replaced by "exrc". =
=C2=A0But only one of ".exrc" and "_exrc" is<br /><span style=3D"white-spac=
e: pre;">	</span>=C2=A0 =C2=A0 used, depending on the system. =C2=A0And wit=
hout the (*)!<br /><span style=3D"white-space: pre;">	</span>V =C2=A0 The d=
efault 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 "s=
yntax on" and "filetype on" commands,<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 folks I know use either ~/.vimrc or ~/.vim/vimr=
c (with equivalent ~/_vimrc or ~/vimfiles/vimrc on Windows).=C2=A0</div></d=
iv></blockquote><div><br /></div><div>I read the documentation, therefore l=
ike with many I also use the system wide .vimrc file when starting vim. I w=
ant to know how to set=C2=A0 the $MYVIMRC as the documentation ?=C2=A0</div=
></div>
</div></blockquote></div><div dir=3D"auto"><blockquote type=3D"cite"><div d=
ir=3D"ltr"></div></blockquote><br /><div>Vim should set it automatically; =
=E2=80=9C:let $MYVIMRC=E2=80=9D should show the value, for example.=C2=A0</=
div><div><br /></div><div>I don=E2=80=99t recommend using the system-wide v=
imrc for anything beyond extremely niche use cases (maybe special hardware =
or software settings?). The per-user vimrc is more predictable to reason ab=
out. In a single-user environment this may matter less, but still.</div></d=
iv></blockquote><div><br /></div><div>In my case running the command ":let =
$MYVIMRC" returns a invalid expression.=C2=A0=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/92e993d6-8baf-4b42-bfee-c7eab4962f9bn%40googlegroups.com?utm_medium=
=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/vim_use/92e=
993d6-8baf-4b42-bfee-c7eab4962f9bn%40googlegroups.com</a>.<br />

------=_Part_52885_1321359255.1773906968364--

------=_Part_52884_1154490626.1773906968364--