Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim/gVim 8.1 on Windows 10 won't source $HOME\_vimrc

Tags:

vim

windows

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?

like image 917
William Linton Avatar asked Nov 02 '25 14:11

William Linton


1 Answers

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.
like image 115
leaf Avatar answered Nov 04 '25 06:11

leaf