On 2026-03-19, Igbanam Ogbuluijah wrote:
> On Wed, Mar 18, 2026 at 10:12:49PM +0000, Gary Johnson wrote:
> > On 2026-03-18, Eric Marceau wrote:
> > > I did a little experiment:
> >
> > [...]
> >
> > I did something similar with terminal vim. I set MYVIMRC directly
> > in my environment and set it in VIMINIT, also in my environment,
> > before starting vim. In all cases, I could see both environment
> > variables within vim and in the environment after shelling out of
> > vim, but in no case was there any evidence of those variables
> > affecting the vimrc sourced by vim at startup. The $MYVIMRC file
> > did not appear in the output of :scriptnames and none of the
> > settings made in that file were set in vim. The only vimrc sourced
> > was the system vimrc, /etc/vim/vimrc on Ubuntu.
> >
> > It does seem like something is broken, because from vim's
> > documentation, I would have expected the file specified by MYVIMRC
> > to have been sourced.
> It's not that something's broken; but there definitely is some
> misconception.
>
> What I think is going on is…
>
> 1. The top two places Vim searches for configuration are
> a. a VIMINIT environment variable
> b. Some VIMRC file
> 2. You can set an environment variable, VIMINIT; it should have Ex
> commands in it.
> 3. If there's no VIMINIT, Vim searches some predefined paths to set
> VIMRC.
>
> I don't think VIMRC is an env variable Vim respects; I think it's an env
> variable it sets based on where it finds a vimrc file.
That's what I used to think, too, was that MYVIMRC was set, but not
read, by Vim. But ":help MYVIMRC" says this:
*$MYVIMRC* *$MYVIMDIR*
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
when using VIMINIT. ...
It's that "unless `$MYVIMRC was already set" that I don't understand
the meaning of. That suggests to me if $MYVIMRC is already set, Vim
uses that value instead of looking further for the file.
In my experiments, I executed
VIMINIT='let $MYVIMRC="/path/to/a/vimrc"' vim
expecting Vim to source /path/to/a/vimrc, but it didn't. I'm OK
with the actual behavior, but I don't think the documentation is
clear.
Regards,
Gary
--
--
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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_use/20260319130425.GD10946%40phoenix.