Thursday, March 19, 2026

Re: $VIMRC over .vimrc ?



On Thursday, March 19, 2026 at 12:29:46 PM UTC-4 D. Ben Knoble wrote:
On Thu, Mar 19, 2026 at 9:45 AM Marvin Renich <mr...@renich.org> wrote:
>
> * Christopher <crestchr...@gmail.com> [260319 03:56]:
> > On Wednesday, March 18, 2026 at 3:48:41 PM UTC-4 Ben Knoble wrote:
> > 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 first that exists
> > is used, the others are ignored. The `$MYVIMRC` environment variable is
> > set to the file that was first found, unless `$MYVIMRC` was already set
>
> and
>
> > 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) (*)
>
> This quote is missing an important word, as shown above.
>
> Perhaps that word should be "or" rather than "and", but either way the
> meaning should be clear:
>
> If VIMINIT is set, it contains ex commands, vim does not search for or
> read any rc file, and MYVIMRC is not set.
>
> If VIMINIT is not set, vim searches for a file in the places listed
> above, and sets MYVIMRC to the file that was found and read.
>
> So, MYVIMRC is not an input to vim, it is how vim communicates to the
> user which file was found and read. If MYVIMRC is exported before
> invoking vim, it is ignored completely; it is neither read nor set.
>
> The user's vimrc file _must_ be one of the files listed above, unless
> you specify the -u option. The only way to specify the vimrc file in an
> environment variable is to export VIMINT="source /path/to/your/vimrc"
> before (or while) starting vim.
>
> The strongly recommended way is to _not_ use VIMINT, and to place your
> vimrc file at ~/.vim/vimrc. VIMINIT is a compatibility holdover.
>
> ...Marvin

Indeed. This is what I meant to convey, and I apologize if my initial
reply was not clear on this point:

Vim sets MYVIMRC for the user, not the other way around!

--
D. Ben Knoble

> The user's vimrc file _must_ be one of the files listed above, unless
> you specify the -u option. The only way to specify the vimrc file in an
> environment variable is to export VIMINT="source /path/to/your/vimrc"
> before (or while) starting vim.  

You mention, the only way to specify a vimrc in a environment variable; I assume as in $MYVIMRC is to export VIMNT which is the source of your vimrc file. If my vimrc file was located in the system path then that would be;
VIMINT=`/etc/vimrc and that would create the environment variable $MYVIMRC ? 

--
--
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

---
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 email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/b3efd6e9-4d4f-4752-af97-2d5666abfd6en%40googlegroups.com.

No comments: