Jonathan.Brink
Jonathan.Brink

Reputation: 25443

$GVIMRC not getting set

I am running on Lubuntu 14.10.

From my bash shell (these all have 777 permissions):

ls -a ~ | grep -i vim
.gvimrc
.vim
.vimrc

From vim, when invoking from my bash terminal emulator:

:echo $HOME
/home/jonbri

:echo $MYVIMRC
/home/jonbri/.vimrc

:echo $MYGVIMRC

For some reason my $MYGVIMRC variable isn't getting set.

Does anyone know why?

Upvotes: 0

Views: 125

Answers (1)

Marth
Marth

Reputation: 24832

The .gvimrc (or _gvimrc) file is only sourced when the GUI is initialized (either from running gvim, vim -g, :gui and possibly other methods I don't know of).
Since $MYGVIMRC is only set when .gvimrc is sourced, it isn't set when using (terminal) vim.

From :help gui-init (some parts removed, emphasis mine) :

When the GUI starts up initializations are carried out, in this order:

  • The 'term' option is set <...>
  • If the system menu file exists, it is sourced. <...>
  • If the "-U {gvimrc}" command-line option <...>
  • For Unix and MS-Windows, if the system gvimrc exists, it is sourced. <...>
  • The following are tried, and only the first one that exists is used:

    • If the GVIMINIT environment variable exists <...>
    • If the user gvimrc file exists, it is sourced. <...>
    • For Win32, when $HOME is not set, "$VIM_gvimrc" is used.
    • When a "_gvimrc" file is not found, ".gvimrc" is tried too. And vice versa. <...>

    The name of the first file found is stored in $MYGVIMRC, unless it was already set.

Upvotes: 2

Related Questions