Question

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.

Was it helpful?

Solution

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?

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top