2
votes

I have a $HOME\_vimrc present, but it doesn't show up in the output of :scriptnames. And when I run gvim -V, it reports:

could not source "$HOME\_vimrc"

The only thing in my $HOME\_vimrc is the following line:

set packpath+=C:\Users\username\vimfiles

In case there was something wrong with that path, I also changed the entire contents of the $HOME\_vimrc file to this, with the same result:

set number

When I run :echo $HOME from gvim, it reports my Windows user profile directory C:\Users\username. I have a $HOME\_gvimrc which it reads fine. My vimfiles directory is at the default $HOME\vimfiles which it seems to read fine, because it's sourcing a color scheme from there.

Running :version shows the following entries:

   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
    [...]
    user gvimrc file: "$HOME\_gvimrc"
    [...]

Running :echo $MYVIMRC outputs C:\Program Files (x86)\Vim\_vimrc.

I've tried running as both administrator and my Windows username.

Someone suggested that I run icacls _vimrc to see the file permissions. Here's the output:

C:\Users\username> icacls _vimrc
_vimrc NT AUTHORITY\SYSTEM:(I)(F)
       BUILTIN\Administrators:(I)(F)
       DOMAIN\username:(I)(F)

That last entry, DOMAIN\username, is the login I'm using to run gVim.

What am I missing?

1
Btw, feel free to checkout Vi and Vim! - D. Ben Knoble
I actually posted it there first. I didn't get a response right away, figured it was a new community and there'd be more Vim users here, so I posted here as well. - William Linton
It’s not that new—besides cross-posting makes it harder to collect information in a single spot. But oh well - D. Ben Knoble

1 Answers

4
votes

Try to define $HOME as a Windows environment variable.

See :h $HOME-windows

                            *$HOME-windows*
On MS-Windows, if $HOME is not defined as an environment variable, then
at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.
If $HOMEDRIVE is not set then $USERPROFILE is used.