Reputation:
I can't work this out, I thought vimrc_example.vim
was an example file but turns out Vim is reading this file for some reason as well as _vimrc.
On windows 10 Home with Vim 8.2.24 not using gvim but vim.
The directory of both these files are:
C:\Program Files\Vim\_vimrc
C:\Program Files\Vim\vim82\vimrc_example.vim
When I delete vimrc_example.vim
it does not start Vim properly then, it just starts with a blank screen then I have to push enter to start up vim. Somewhere my vim is telling it to read this file I just don't understand the how and why as I am new to vim.
The reason I realised this is I was trying to set tw=0
via _vimrc
but turned out vimrc_example.vim
kept overriding this and setting it back to 78. I have tried to google a solution to this, but I just thought common sense wise an example file should not be this relevant and if it is why?
Output of :scriptnames
1: C:\Program Files\Vim\_vimrc
2: C:\Program Files\Vim\vim82\vimrc_example.vim
3: C:\Program Files\Vim\vim82\defaults.vim
4: C:\Program Files\Vim\vim82\syntax\syntax.vim
5: C:\Program Files\Vim\vim82\syntax\synload.vim
6: C:\Program Files\Vim\vim82\syntax\syncolor.vim
7: C:\Program Files\Vim\vim82\filetype.vim
8: C:\Program Files\Vim\vim82\ftplugin.vim
9: C:\Program Files\Vim\vim82\indent.vim
10: C:\Program Files\Vim\vim82\autoload\plug.vim
11: C:\Program Files\Vim\vim82\ftoff.vim
12: C:\Program Files\Vim\vim82\syntax\nosyntax.vim
13: ~\.vim\plugged\vim-monokai\colors\monokai.vim
14: ~\.vim\plugged\vim-wakatime\plugin\wakatime.vim
15: ~\.vim\plugged\vim-airline\plugin\airline.vim
16: ~\.vim\plugged\vim-airline\autoload\airline\init.vim
17: ~\.vim\plugged\vim-airline\autoload\airline\parts.vim
18: ~\.vim\plugged\vim-airline\autoload\airline\util.vim
19: ~\.vim\plugged\vim-airline-themes\plugin\airline-themes.vim
20: ~\.vim\plugged\vim-clang-format\plugin\clang_format.vim
21: ~\.vim\plugged\vim-gitgutter\plugin\gitgutter.vim
22: ~\.vim\plugged\vim-gitgutter\autoload\gitgutter\utility.vim
23: ~\.vim\plugged\vim-gitgutter\autoload\gitgutter\highlight.vim
24: ~\.vim\plugged\vim-gitgutter\autoload\gitgutter\async.vim
25: ~\.vim\plugged\DrawIt\plugin\cecutil.vim
26: ~\.vim\plugged\DrawIt\plugin\DrawItPlugin.vim
27: C:\Program Files\Vim\vim82\plugin\getscriptPlugin.vim
28: C:\Program Files\Vim\vim82\plugin\gzip.vim
29: C:\Program Files\Vim\vim82\plugin\logiPat.vim
30: C:\Program Files\Vim\vim82\plugin\manpager.vim
31: C:\Program Files\Vim\vim82\plugin\matchparen.vim
32: C:\Program Files\Vim\vim82\plugin\netrwPlugin.vim
33: C:\Program Files\Vim\vim82\plugin\rrhelper.vim
34: C:\Program Files\Vim\vim82\plugin\spellfile.vim
35: C:\Program Files\Vim\vim82\plugin\tarPlugin.vim
36: C:\Program Files\Vim\vim82\plugin\tohtml.vim
37: C:\Program Files\Vim\vim82\plugin\vimballPlugin.vim
38: C:\Program Files\Vim\vim82\plugin\zipPlugin.vim
39: C:\Program Files\Vim\vim82\pack\dist\opt\matchit\plugin\matchit.vim
40: ~\.vim\plugged\vim-airline\autoload\airline\extensions.vim
41: ~\.vim\plugged\vim-airline\autoload\airline\extensions\quickfix.vim
42: ~\.vim\plugged\vim-airline\autoload\airline.vim
43: ~\.vim\plugged\vim-airline\autoload\airline\extensions\netrw.vim
44: ~\.vim\plugged\vim-airline\autoload\airline\extensions\term.vim
45: ~\.vim\plugged\vim-airline\autoload\airline\section.vim
46: ~\.vim\plugged\vim-airline\autoload\airline\highlighter.vim
47: ~\.vim\plugged\vim-airline\autoload\airline\extensions\hunks.vim
48: ~\.vim\plugged\vim-airline\autoload\airline\extensions\whitespace.vim
49: ~\.vim\plugged\vim-airline\autoload\airline\extensions\wordcount.vim
50: ~\.vim\plugged\vim-airline\autoload\airline\extensions\keymap.vim
51: ~\.vim\plugged\vimtex\autoload\vimtex.vim
52: ~\.vim\plugged\vim-airline\autoload\airline\extensions\vimtex.vim
53: ~\.vim\plugged\vim-airline-themes\autoload\airline\themes\molokai.vim
54: ~\.vim\plugged\vim-airline\autoload\airline\themes.vim
55: ~\.vim\plugged\vim-airline\autoload\airline\builder.vim
56: ~\.vim\plugged\vim-airline\autoload\airline\extensions\default.vim
57: ~\.vim\plugged\vim-gitgutter\autoload\gitgutter.vim
58: ~\.vim\plugged\vim-gitgutter\autoload\gitgutter\hunk.vim
https://i.gyazo.com/7ca9c5002ec1f95aa545c859b498cba5.png
Files:
_vimrc located in C:\program files\Vim\_vimrc
:
vimrc_example.vim located in C:\Program Files\Vim\vim82
:
You see I would think you could delete vimrc_example but not sure if it is doing anything important?????? Please refer to the specific line numbers if you wish to point out anything incorrect.
Upvotes: 3
Views: 934
Reputation: 8908
Your C:\Program Files\Vim\_vimrc
has this on line 7:
" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
That's what's sourcing the vimrc_example.vim
file. So it looks like you added this there, or copied it from somewhere (perhaps a guide or tip you found on the web?) or this _vimrc
file is one you downloaded (or came with a Vim distribution you installed?) and had this in it already.
Anyways, that should explain why vimrc_example.vim
is being sourced.
If you don't want that behavior anymore, you can either:
source
command from C:\Program Files\Vim\_vimrc
_vimrc
file (because it came with a distro or similar), then you can instead start using a _vimrc
file from a different location (note that this one corresponds to the one listed as "3rd user vimrc file" in the :version
output, you could use $HOME/_vimrc
or $HOME/vimfiles/vimrc
that come before it.)Note that the vimrc_example.vim
file is not really originally meant to be sourced this way... Instead, it's meant to be a template for you to copy to your own _vimrc
that you can then modify to your taste. So while you'll probably be fine with sourcing it, it's not how it was meant to be used.
You'll also note that the vimrc_example.vim
file doesn't actually have a lot of commands itself... But a lot of what it does is actually coming from defaults.vim
that is sourced from it. Please note that the defaults.vim
file is meant to be sourced from your vimrc (see :help defaults.vim
for more details.)
So you might want to consider swapping the sourcing of vimrc_example.vim
with the sourcing of defaults.vim
. Additionally, if you like some of the other settings from vimrc_example.vim
(such as enabling backup
and undofile
), consider replicating those into your vimrc.
Upvotes: 4