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.

Is there something I'm missing?


The output of icacls _vimrc:

C:\Users\username> icacls _vimrc

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

  • 1
    What's the output of "icacls _vimrc"? This will display your permissions for the file. – Rob Mosher Oct 28 '19 at 15:52
  • 1
    Welcome to Vi and Vim! Rob's suggestion is a good place to start (this could be a permissions error). Please edit your question as you provide new details – D. Ben Knoble Oct 28 '19 at 15:53
  • I've updated the question to include the output. Let me know if you need more details. – William L. Oct 28 '19 at 17:04
  • @RobMosher I can't read windows stuff there, so idk if that's right – D. Ben Knoble Oct 29 '19 at 0:55
  • The (F)s indicate ful read/write access for each of those users. But it looks like William found the answer. – Rob Mosher Oct 30 '19 at 12:10

The solution was to define $HOME as a Windows environment variable.

Once I did that and restarted gVim, it read my ~\_vimrc and also sourced my native Vim 8.1 packages correctly.

Source: this answer at Stack Overflow.

| improve this answer | |
  • 1
    Fallback to $HOMEDRIVE$HOMEPATH or $USERPROFILE should usually take care of that... Do you not have those defined in your environment for some reason? – filbranden Oct 29 '19 at 15:09
  • 1
    Ah, $HOMEDRIVE$HOMEPATH is set to M:\ , which is a mapped network drive. $USERPROFILE is set to C:\Users\username. If it was using$HOMEDRIVE$HOMEPATH, it would explain why it couldn't find my _vimrc, but then why does :echo $HOME show C:\users\username? – William L. Oct 29 '19 at 16:36
  • You might want to update your answer to reflect that. Yeah it's odd that :echo $HOME is showing the other path... Not sure why that would happen... – filbranden Oct 29 '19 at 16:48
  • It may be that vim is setting $HOME itself somehow, or that it is coming from somewhere else. I would open up a windows terminal, and get the environment value HOME (I think the syntax on cmd is %HOME% or something) – D. Ben Knoble Oct 29 '19 at 16:52
  • %HOME% was not set in Windows. Once I set it in Windows, gVim started reading my ~\_vimrc. – William L. Oct 31 '19 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.