2

I have installed gvim on Windows.

In order for gvim to find my .vimrc file I have set the $VIM (%VIM%) environment variable, pointing to the directory in which this .vimrc file is located.

I have not set $VIMRUNTIME since :help $vimruntime says

You don't normally set $VIMRUNTIME yourself, but let Vim figure it out.

When I start gvim, it processes my .vimrc file, as expected, until the line with the command sy on. This command tries to load the syntax files, but it can't.

I suspect the reason is this: As I have not set $VIMRUNTIME, vim automatically sets it to the value of $VIM. But under $VIM, there is no syntax/syntax.vim file. This syntax file is, however, under c:\vim\vim73\syntax.

So, If I set $VIMRUNTIME specifically to c:\vim\vim73, everything seems to work.

Now, why does the helpfile say I don't need to set $VIMRUNTIME if obviously I have to.

René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293

2 Answers2

3

Usually, you place your _vimrc, _gvimrc and the directory with your custom files (vimfiles) within your $HOME directory.

Vim searches there by default.

Files located there won't be overridden when updating your Vim installation, so it's generally a good idea to do this and you won't have to mess around with any variables. If you have any custom plugins, syntax files etc, place them below vimfiles/plugins, vimfiles/syntax etc.

Furthermore, you could ask Vim where it searches for vimrc's using :version:

   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 described here: How to locate the vimrc file used by vim editor?

Community
  • 1
  • 1
eckes
  • 64,417
  • 29
  • 168
  • 201
1

I would rather set the $HOME environment variable to make Vim pick up your user's .vimrc (and potential plugins under .vim/...). The location of $VIM is supposed to represent the Vim installation base directory (including the runtime and support files).

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • This is certainly possible, but seems a bit of an overkill, since I need the $HOME variable in other applications too, and I don't want to mess with those applications just only because I want vim to find my .vimrc. In addition to that, I want to install some scripts and personal plugins in a non standard location so that I can have them under revision control and so that they're not overwritten when vim is re-installed. – René Nyffenegger Mar 03 '14 at 12:46