Is there a command in the vim editor to find the .vimrc file location?
Asked
Active
Viewed 1.1e+01k times
168
Jonas Stein
- 6,363
- 7
- 39
- 70
niting112
- 2,348
- 2
- 15
- 17
3 Answers
256
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).
Skippy le Grand Gourou
- 5,996
- 4
- 52
- 70
manojlds
- 275,671
- 58
- 453
- 409
-
24To clarify: `:version` tells what locations are searched, but doesn't give any info regarding what files were found. For that the $MYVIMRC variable is useful, as is looking at output of `:scripts` for full list of all loaded script files, including all vimrc files. – Herbert Sitz Jan 23 '12 at 20:38
-
20@HerbertSitz `:scripts` -> `:scriptnames` (innocent typo) – Randy Morris Jan 23 '12 at 23:54
-
4:echo $MYVIMRC was exactly what I was looking for. Cheers! – theINtoy Aug 12 '14 at 14:10
-
7I'm running vim 7.4 on OSX 10.10.5 installed with Homebrew, and `:echo $MYVIMRC` outputs nothing. – Heath Borders Dec 09 '15 at 01:04
-
1`:echo $MYVIMRC` also echos nothing for me. Not in Git Bash, not in Babun, not on my remote linux server. – DanGordon Dec 23 '15 at 17:48
-
6I know this is like two years old but regarding the last two comments. I got a blank output when running that command from the command line however when opening vim then typing ":echo $MYVIMRC" I got the real vimrc file. – Four_0h_Three Aug 09 '17 at 04:33
-
@Four_0h_Three Yeah, the : prompt shows it should be typed within Vim, not on the command line. – Jan 25 '18 at 09:58
-
On Arch Linux, sudo would NOT honor `/etc/vimrc` until I `ln -s` it to `/root/.vimrc`. – Theodore R. Smith May 05 '19 at 15:25
-
I have user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" but 2nd user vimrc file doesn't take effect, i need to put everything i want in $HOME/.vimrc what i'm missing? – Bashar Al-Abdulhadi Aug 09 '20 at 15:36
4
:version does not list /etc/vim but this is where vim is picking up gvimrc and vimrc on my ubuntu box running vim82 from vim-gtk3
Jeremy Woodland
- 2,904
- 4
- 13
- 23