niting112
niting112

Reputation: 2640

How to locate the vimrc file used by Vim?

Is there a command in the Vim editor to find the .vimrc file location?

Upvotes: 192

Views: 140947

Answers (4)

Jeremy Woodland
Jeremy Woodland

Reputation: 3745

:version does not provide a complete and exhaustive list.

It does not list /etc/vim for example, despite this being the path vim uses to pick up gvimrc and vimrc on my Ubuntu box running vim82 from vim-gtk3.

Upvotes: 8

RicHincapie
RicHincapie

Reputation: 3973

Run :script, which will show you all the locations where VIM is loading files from. Probably, your source file is located somewhere in those directories. If you find a different source file, you may insert the following in it:

if filereadable("/my/directory/.vim/.vimrc")
   source /my/directory/.vim/.vimrc
endif

And VIM will load your custom config file wherever it is.

Check it is working by looking for it in the output of :script

Upvotes: 9

mickours
mickours

Reputation: 1243

For nvim use :scriptnames like proposed in Randy Morris comment

Upvotes: 9

manojlds
manojlds

Reputation: 301147

Just try doing the following:

:version

You will get an output which includes something like:

 system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"

As noted by Herbert in comments, this is where vim looks for vimrcs, it doesn't mean they exist.

You can check the full path of your vimrc with

:echo $MYVIMRC

If the output is empty, then your vim doesn't use a user vimrc (just create it if you wish).

Upvotes: 287

Related Questions