Where should the .vimrc file be located on Windows 7?

181

55

I recently installed vim on Windows 7 as a stand-alone binary.

Where should I put my .vimrc file?

AJ.

Posted 2009-12-21T21:07:42.027

Reputation: 3 491

See also: http://stackoverflow.com/questions/10921441/where-is-my-vimrc-file

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2016-03-24T10:32:00.693

But is it not true that on Windows it is a _vimrc file? – Kazark – 2011-11-29T16:34:26.007

4Windows gvim (either Cygwin or Native) will opt for _gvimrc, .gvimrc, _vimrc and finally _vimrc in that order of priority. It unders the underscore and dot format for the vimrc. – Darren Hall – 2012-01-17T22:04:48.723

Answers

210

From the Vim Wiki.

In Vim, your home directory is specified with $HOME. On Unix systems, this is your ~ directory. On Windows systems, the best way to find the value of $HOME is from within Vim, as follows. These commands are useful to see what directories your Vim is using:

:version
:echo expand('~')
:echo $HOME
:echo $VIM
:echo $VIMRUNTIME

Once you determine the HOME variable put the vimrc file within that directory.

If you would like to change your HOME variable, set HOME as an environment variable for either the system or user.

Computer > Properties > Advanced System Settings > Advanced > Environment Variables > User | System Variables.

Windows (both Native and Cygwin*) will use _gvimrc, .gvimrc, _vimrc and .vimrc in that order of priority. The gvim* files will be checked with the gvim process, while the console vim will only check the vim* files.

*: verified against vim 7.2 and 7.3

Darren Hall

Posted 2009-12-21T21:07:42.027

Reputation: 6 354

3(For those like me, who only use Windows when forced to): remember to enable showing file extensions. "_gvimrc.txt" etc. doesn't work. ;) – Stein G. Strindhaug – 2014-12-11T17:02:20.463

To have HOME match the behavior of Unix systems, I'd create a global environmental variable of %USERPROFILE% if that's not already done. – Pluto – 2015-08-25T21:02:01.400

22

For Vim 7.4, these are the paths it looks for on Windows

   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
    system menu file: "$VIMRUNTIME\menu.vim"

As Darren Hall said, use these commands to find out the values of $VIM and $HOME.

:echo $HOME
:echo $VIM

For example, one good place for gvim-specific settings would be

C:\Users\MyUsername\_gvimrc

Christian Long

Posted 2009-12-21T21:07:42.027

Reputation: 1 371

5

Easiest way I found is to simply echo the location of the vimrc file currently in use - you can then replace with your own custom version.

:echo $MYVIMRC

Patrick

Posted 2009-12-21T21:07:42.027

Reputation: 151

4

If you need to find out just from a .bat file first look in the %HOME% directory. If that is not defined then vim/gvim looks in the path defined by concatenating %HOMEDRIVE% and %HOMEPATH%.

Philip

Posted 2009-12-21T21:07:42.027

Reputation: 569

1

That is actually a good question because after installation (oddly enough) you get a _vimrc file under "Program Files" - which is not a good place for configuration files.

Put it under

%USERPROFILE%\vimfiles\_vimrc

This way it will be picked up instead of the configuration file put by the installation.

kroiz

Posted 2009-12-21T21:07:42.027

Reputation: 223

0

I found that vim-tux installed via Chocolatey can see .vimrc files only under C:\Users\MyUsername\vimfiles though :version tells that C:\Users\MyUsername also included.

Alex Shwarc

Posted 2009-12-21T21:07:42.027

Reputation: 101

0

I find that when I open gvim from Windows file explorer, $HOME is set to c:\Users\myname but when launched from my Cygwin file explorer it is set to /cygwin/home/myname. This is good because it lets me put slightly different settings in each one. To keep things separate and make backup easier, the Windows one is called _vimrc and the Cygwin one is called .vimrc.

stark

Posted 2009-12-21T21:07:42.027

Reputation: 101

0

I found it in ( windows 10 )

\tools\vim\_vimrc

Romain Donck

Posted 2009-12-21T21:07:42.027

Reputation: 1