Re: $VIMRC over .vimrc ?
"D. Ben Knoble" <[email protected]> Thu, 19 Mar 2026 12:28:26 -0400
| Newsgroups | gmane.editors.vim |
|---|---|
| Message-ID | <CALnO6CCnU44Aahyt2fLVbJ59BBm-VBJOiWHL-L8REi+oibcW4A@mail.gmail.com> |
On Thu, Mar 19, 2026 at 3:56=E2=80=AFAM Christopher <crestchristopher@gmail= .com> wrote: > > > > 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= =A9crit : > > =EF=BB=BF > > > > 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 ? > > > I'm afraid your question isn't clear to me, but let's look at `:help myvi= mrc`: > > 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) (*) > > 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 = _by Vim_ to the file it finds. > > Most folks I know use either ~/.vimrc or ~/.vim/vimrc (with equivalent ~/= _vimrc or ~/vimfiles/vimrc on Windows). > > > 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 ? > > > Vim should set it automatically; =E2=80=9C:let $MYVIMRC=E2=80=9D should s= how the value, for example. > > I don=E2=80=99t recommend using the system-wide vimrc for anything beyond= extremely niche use cases (maybe special hardware or software settings?). = The per-user vimrc is more predictable to reason about. In a single-user en= vironment this may matter less, but still. > > > In my case running the command ":let $MYVIMRC" returns a invalid expressi= on. Indeed. Should be ":echo $MYVIMRC" then. (I usually go with :let for=E2=80= =A6 reasons=E2=80=A6 but it apparently doesn't work here.) --=20 D. Ben Knoble --=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/CAL= nO6CCnU44Aahyt2fLVbJ59BBm-VBJOiWHL-L8REi%2BoibcW4A%40mail.gmail.com.