Here is the snapshot for:scriptname
1: /etc/vimrc
2: /usr/share/vim/vim72/syntax/syntax.vim
3: /usr/share/vim/vim72/syntax/synload.vim
4: /usr/share/vim/vim72/syntax/syncolor.vim
5: /usr/share/vim/vim72/filetype.vim
6: /usr/share/vim/vim72/ftplugin.vim
7: /home/xxxxx/.vimrc
8: /usr/share/vim/vim72/syntax/nosyntax.vim
9: /usr/share/vim/vim72/indent.vim
10: /usr/share/vim/vim72/colors/desert.vim
11: /usr/share/vim/vim72/indoff.vim
12: /usr/share/vim/vim72/ftplugof.vim
13: /usr/share/vim/vim72/plugin/filetype.vim
14: /usr/share/vim/vim72/plugin/getscriptPlugin.vim
15: /usr/share/vim/vim72/plugin/gzip.vim
16: /usr/share/vim/vim72/plugin/matchparen.vim
17: /usr/share/vim/vim72/plugin/netrwPlugin.vim
18: /usr/share/vim/vim72/plugin/rrhelper.vim
19: /usr/share/vim/vim72/plugin/spellfile.vim
20: /usr/share/vim/vim72/plugin/tarPlugin.vim
21: /usr/share/vim/vim72/plugin/tohtml.vim
22: /usr/share/vim/vim72/plugin/vimballPlugin.vim
23: /usr/share/vim/vim72/plugin/zipPlugin.vim
24: /usr/share/vim/vim72/syntax/cpp.vim
25: /usr/share/vim/vim72/syntax/c.vim
26: /home/xxxxx/.vim/after/syntax/cpp.vim
On 7, my vimrc is being sourced and after that couple of .vim files are being sourced.
How do I stop these default sourcing of .vim files?
Use The Noplugin Option when starting Vim
Please look at the help file, :help starting. BTW, the :help initialization section is a good read too.
The section on --noplugin describes the resulting options behavior:
--noplugin Skip loading plugins. Resets the 'loadplugins' option.
Note that the |-u| argument may also disable loading plugins:
argument load: vimrc files plugins defaults.vim ~
(nothing) yes yes yes
-u NONE no no no
-u DEFAULTS no no yes
-u NORC no yes no
--noplugin yes no yes
Thus, Starting vim with this option will execute your vimrc, but not source plugins (though you will get defaults...):
vim --noplugin
As phd had indicated, your settings in your ~/.vimrc file are also responsible for the *.vim files being sourced as well (e.g. filetype settings, indentation, colorscheme).
When I execute the ex command (Vim 8.2 on Windows 10), :scriptname, I get:
1: ~\_vimrc
2: C:\Program Files\Vim\vim82\vim82\filetype.vim
3: C:\Program Files\Vim\vim82\vim82\ftplugin.vim
4: C:\Program Files\Vim\vim82\vim82\indent.vim
5: C:\Program Files\Vim\vim82\vim82\syntax\syntax.vim
6: C:\Program Files\Vim\vim82\vim82\syntax\synload.vim
7: C:\Program Files\Vim\vim82\vim82\syntax\syncolor.vim
8: C:\Program Files\Vim\vim82\vim82\colors\murphy.vim
9: C:\Program Files\Vim\vim82\vim82\ftplugin\help.vim
10: C:\Program Files\Vim\vim82\vim82\syntax\help.vim
Press ENTER or type command to continue
Vim Verbose Logging Can Provide a Detailed Perspective on Plug-in Sourcing
When starting Vim, you can use the verbose option with the verbosefile set, you can view the initialization process in as detailed a manner as you would like.
the :help -V entry:
-V[N] Verbose. Sets the 'verbose' option to [N] (default: 10).
Messages will be given for each file that is ":source"d and
for reading or writing a viminfo file. Can be used to find
out what is happening upon startup and exit.
Example:
vim -V8 foobar
I started my vim session with vim --noplugin -V6vim_logging6.txt (here N can be 1 to 10 (10 being the most logging)). Also, I set the logging file, verbosefile, to "logging6.txt".
For our purposes of viewing the sourcing, I scrape the log file with this ex command to view just the sourcing:
:v/^line \d\+/d
I can then view the sequential sourcing only from the log file:
1 line 28: sourcing "/usr/local/share/vim/vim82/filetype.vim"
2 line 28: sourcing "/usr/local/share/vim/vim82/ftplugin.vim"
3 line 29: sourcing "/usr/local/share/vim/vim82/filetype.vim"
4 line 29: sourcing "/usr/local/share/vim/vim82/ftplugin.vim"
5 line 29: sourcing "/usr/local/share/vim/vim82/indent.vim"
6 line 30: sourcing "/usr/local/share/vim/vim82/syntax/syntax.vim"
7 line 19: sourcing "/usr/local/share/vim/vim82/syntax/synload.vim"
8 line 21: sourcing "/usr/local/share/vim/vim82/syntax/syncolor.vim"
9 line 66: sourcing "/usr/local/share/vim/vim82/colors/murphy.vim"
10 line 7: sourcing "/usr/local/share/vim/vim82/syntax/syncolor.vim"
11 line 8: sourcing "/usr/local/share/vim/vim82/syntax/syncolor.vim"
12 line 10: sourcing "/usr/local/share/vim/vim82/syntax/syncolor.vim"
13 line 119: sourcing "/home/pbacon/.vimrc.plug"
14 line 1: sourcing "/home/pbacon/.vim/autoload/plug.vim"
15 line 14: sourcing "/usr/local/share/vim/vim82/ftoff.vim"
16 line 83: sourcing "/usr/local/share/vim/vim82/filetype.vim"
17 line 83: sourcing "/usr/local/share/vim/vim82/ftplugin.vim"
18 line 83: sourcing "/usr/local/share/vim/vim82/indent.vim"
Related
I installed the rust.vim plugin in ~/.vim/pack/plugins/start. If I open a file called main.rs and type
:scriptnames, here is the output
`
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: /usr/share/vim/vim74/ftplugin.vim
8: /usr/share/vim/vim74/indent.vim
9: ~/.vim/plugin/ScrollColor.vim
10: ~/.vim/plugin/color_sample_pack.vim
11: ~/.vim/plugin/mimicpak.vim
12: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
13: /usr/share/vim/vim74/plugin/gzip.vim
14: /usr/share/vim/vim74/plugin/logiPat.vim
15: /usr/share/vim/vim74/plugin/matchparen.vim
16: /usr/share/vim/vim74/plugin/netrwPlugin.vim
17: /usr/share/vim/vim74/plugin/rrhelper.vim
18: /usr/share/vim/vim74/plugin/spellfile.vim
19: /usr/share/vim/vim74/plugin/tarPlugin.vim
20: /usr/share/vim/vim74/plugin/tohtml.vim
21: /usr/share/vim/vim74/plugin/vimballPlugin.vim
22: /usr/share/vim/vim74/plugin/zipPlugin.vim
23: ~/.vim/pack/plugins/start/rust.vim/plugin/cargo.vim
24: ~/.vim/pack/plugins/start/rust.vim/plugin/rust.vim
25: ~/.vim/pack/plugins/start/rust.vim/ftdetect/rust.vim
26: /usr/share/vim/vim74/syntax/hercules.vim
`
If I type :set ft, here is the output:
filetype=hercules
Output of :autocmd filetypedetect pertaining to hercules:
*.vc setf hercules
*.ev setf hercules
*.rs setf hercules
*.sum setf hercules
*.errsum setf hercules
There is no lines pertaining to rust
Output of :20verbose e main.rs pertaining to hercules:
Executing BufRead Auto commands for "*.rs"
autocommand setf hercules
line 0: setf hercules
followed by a bunch of lines about the formatting of hercuels.
Searching for "/.vim/ftplugin/hercules.vim"
Searching for "/.vim/ftplugin/hercules_*.vim"
Searching for "/.vim/ftplugin/hercules/*.vim"
Searching for "/.vim/pack/plugins/start/rust.vim/ftplugin/hercules.vim"
Searching for "/.vim/pack/plugins/start/rust.vim/ftplugin/hercules_*.vim"
Searching for "/.vim/pack/plugins/start/rust.vim/ftplugin/hercules/*.vim"
Searching for "/var/lib/vim/addons/ftplugin/hercules.vim"
Searching for "/var/lib/vim/addons/ftplugin/hercules_*.vim"
Searching for "/var/lib/vim/addons/ftplugin/hercules/*.vim"
Searching for "/usr/share/vim/vimfiles/ftplugin/hercules.vim"
This block of Searching for gets repeated later as well. At the very end of the output is this:
Executing BufRead Auto commands for "*.rs"
autocommand setf rust
line 0: setf rust
Executing BufEnter Auto commands for "*"
autocommand sil call s:LocalBrowse(expand("<amatch>"))
line 0: sil call s:LocalBrowse(expand("<amatch>"))
Can anybody tell me how to make vim read the filetype as rust instead of hercules?
Check the output of :autocmd filetypedetect. For me (Vim 8.1.744), the following patterns apply to hercules / rust. (I don't know what the rust.vim plugin does, but at least filetype detection, plugin, and syntax already ship with Vim itself.)
*.vc setf hercules
*.ev setf hercules
*.sum setf hercules
*.errsum setf hercules
[...]
*.rs setf rust
For you, the output presumably is different. You need to find out where the wrong pattern comes from. One way is observing all commands executed when opening the file:
:20verbose e main.rs
If the hercules filetype has precedence over the rust one (as seems to be the case based on your edits), you either have to remove the hercules one (I wonder where that *.rs glob comes from, even my old Vim 7.4 doesn't have it), or define an override as described in :help new-filetype: A. If you want to overrule all default file type checks. That is, create a file ~/.vim/ftdetect/rust.vim with:
au BufRead,BufNewFile *.rs set filetype=rust
Note the difference: :set filetype= is unconditional setting, whereas the :setf used by the default rules only sets if it isn't defined yet (so hercules, coming first, wins for you so far).
My .vimrc has a string "set tabstop=4", but it doesn't apply when i open something, for example, python file. Here's my full .vimrc:
cnoremap Q q
au! BufWritePost .vimrc source %
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab
set softtabstop=4
set autoindent
"set syntax=off
set t_co=256
strace says vim reads /home/user/.vimrc, and he really reads this file, for example, cnoremap works, he replaces :Q by :q as expected, but if i, for example, uncomment set syntax=off, it does not apply.
Also, vim -V2 says next:
...
считывание сценария "$HOME/.vimrc"
Поиск "syntax/off.vim syntax/off/*.vim" в "/home/user/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,/home/user/.vim/after"
not found in 'runtimepath': "syntax/off.vim syntax/off/*.vim"
...
Of course, i thought, it was something with options. But if i made in editor :so $MYVIMRC, he applies all settings!
Right now i live with bash alias vim="vim -S ~/.vimrc", and in verbose mode he applies .vimrc without errors and works as expected, but that's weird solution.
What could be wrong here? And why vim does not apply tabstop/syntax from .vimrc?
Output of :verb set ts
tabstop=8
В последний раз опция изменена в /usr/share/vim/vim80/ftplugin/python.vim
Output of :scriptnames
1: /etc/vimrc
2: /usr/share/vim/vim80/syntax/syntax.vim
3: /usr/share/vim/vim80/syntax/synload.vim
4: /usr/share/vim/vim80/syntax/syncolor.vim
5: /usr/share/vim/vim80/filetype.vim
6: /usr/share/vim/vimfiles/ftdetect/dockerfile.vim
7: /usr/share/vim/vimfiles/ftdetect/nginx.vim
8: /usr/share/vim/vimfiles/ftdetect/stp.vim
9: /usr/share/vim/vim80/ftplugin.vim
10: ~/.vimrc
11: /usr/share/vim/vim80/plugin/getscriptPlugin.vim
12: /usr/share/vim/vim80/plugin/gzip.vim
13: /usr/share/vim/vim80/plugin/logiPat.vim
14: /usr/share/vim/vim80/plugin/manpager.vim
15: /usr/share/vim/vim80/plugin/matchparen.vim
16: /usr/share/vim/vim80/plugin/netrwPlugin.vim
17: /usr/share/vim/vim80/plugin/rrhelper.vim
18: /usr/share/vim/vim80/plugin/spellfile.vim
19: /usr/share/vim/vim80/plugin/tarPlugin.vim
20: /usr/share/vim/vim80/plugin/tohtml.vim
21: /usr/share/vim/vim80/plugin/vimballPlugin.vim
22: /usr/share/vim/vim80/plugin/zipPlugin.vim
23: /usr/share/vim/vim80/syntax/python.vim
24: /usr/share/vim/vim80/ftplugin/python.vim
If the output of the command :verbose set tabstop? in a python buffer is:
tabstop=8
В последний раз опция изменена в /usr/share/vim/vim80/ftplugin/python.vim
It means that the filetype plugin /usr/share/vim/vi80/ftplugin/python.vim sets the value of your 'tabstop' option, local to the current python buffer, with 8 while you want 4.
Your setting set tabstop=4 doesn't take effect in a python buffer, because a local value has priority over a global one.
If you want to override this, you could create the file ~/.vim/after/ftplugin/python.vim and write inside:
setlocal tabstop=4
Or you could add the following autocmd inside your vimrc:
augroup my_python_settings
autocmd!
autocmd FileType python setlocal tabstop=4
augroup END
You may have the issue referred here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864074
The solution is to uncomment the following line in /etc/vim/vimrc (by removing the " at the beginning of the line):
let g:skip_defaults_vim = 1
For me it was the set mouse=a which forced the Visual mode in vim 8.0, and didn't in vim 7.4.
I have a nice .vimrc file with my preferred settings. One of the settings is tabstop=4. But when I'm on a server that I often work on, the tabstop setting that I apply in my ~/.vimrc gets clobbered by a script that's loaded later (/usr/share/vim/vim74/ftplugin/python.vim). Those scripts are owned by root, and I can't change them. Nor do I want to. I just want the last word on any given setting.
Where or how can I get the last word on vim settings?
if I start vim and do :scriptnames, I get this output:
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: ~/.vimrc
8: /usr/share/vim/vim74/indent.vim
9: /usr/share/vim/vim74/ftplugin.vim
10: /usr/share/vim/vim74/syntax/nosyntax.vim
11: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
12: /usr/share/vim/vim74/plugin/gzip.vim
13: /usr/share/vim/vim74/plugin/matchparen.vim
14: /usr/share/vim/vim74/plugin/netrwPlugin.vim
15: /usr/share/vim/vim74/plugin/rrhelper.vim
16: /usr/share/vim/vim74/plugin/spellfile.vim
17: /usr/share/vim/vim74/plugin/tarPlugin.vim
18: /usr/share/vim/vim74/plugin/tohtml.vim
19: /usr/share/vim/vim74/plugin/vimballPlugin.vim
20: /usr/share/vim/vim74/plugin/zipPlugin.vim
21: /usr/share/vim/vim74/indent/python.vim
22: /usr/share/vim/vim74/ftplugin/python.vim
23: /usr/share/vim/vim74/syntax/python.vim
24: /usr/share/vim/vim74/scripts.vim
25: /usr/share/vim/vim74/indent/vim.vim
26: /usr/share/vim/vim74/ftplugin/vim.vim
27: /usr/share/vim/vim74/syntax/vim.vim
EDIT
It's the script /usr/share/vim/vim74/ftplugin/python.vim that's clobbering my tabstop setting. If I do :verbose set tabstop I get:
tabstop=8
Last set from /usr/share/vim/vim74/ftplugin/python.vim
--- edit ---
Put setlocal tabstop=4 in ~/.vim/after/ftplugin/python.vim or add these lines to ~/.vimrc:
augroup Python
autocmd!
autocmd Filetype python setlocal tabstop=4
augroup END
~/.vimrc is the right place to put most of your settings. For rare situations like this, when plugins override your settings, you have two possible strategies: autocommands and the after directory.
Using the after directory is somewhat "safer" but it has the downside of making your setup a bit more complicated. It is my recommended strategy. See :help after-directory.
Using autocommands is more "hacky" but it allows you to keep everything in one place. See :help autocommand.
--- endedit ---
You must use the -u flag to source a non-default vimrc:
$ vim -u /path/to/my/fancy/vimrc
But you don't have to do anything if your vimrc is located at the root of your $HOME directory.
Vim will find it and source it without any user intervention, as explained in :help startup, :help starting.txt and, more specifically, in :help vimrc.
In addition to all that reading, I'd suggest bookmarking this document for future reference.
Version: gvim, version 7.4.52
OS: Linux Mint 17
.vimrc (only 2 lines!):
autocmd BufRead,BufNewFile *.log set syntax=log4j
autocmd BufRead,BufNewFile program_log set syntax=log4j
.vim directory in home:
-syntax (directory)
--log4j.vim (plugin's file)
Result: all my *.log and program_log looks "black and white".
UPDATE
output of :scriptnames (for file.log):
1: /usr/share/vim/vimrc
2: /usr/share/vim/vim74/debian.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: /usr/share/vim/vim74/menu.vim
8: /usr/share/vim/vim74/autoload/paste.vim
9: ~/.vimrc
10: /usr/share/vim/vim74/plugin/getscriptPlugin.vim
11: /usr/share/vim/vim74/plugin/gzip.vim
12: /usr/share/vim/vim74/plugin/matchparen.vim
13: /usr/share/vim/vim74/plugin/netrwPlugin.vim
14: /usr/share/vim/vim74/plugin/rrhelper.vim
15: /usr/share/vim/vim74/plugin/spellfile.vim
16: /usr/share/vim/vim74/plugin/tarPlugin.vim
17: /usr/share/vim/vim74/plugin/tohtml.vim
18: /usr/share/vim/vim74/plugin/vimballPlugin.vim
19: /usr/share/vim/vim74/plugin/zipPlugin.vim
20: /usr/share/vim/gvimrc
21: /usr/share/vim/vim74/scripts.vim
Colorscheme by default.
Syntaxes for files from /usr/share/vim/vim74/syntax work well (java, css, html, etc).
After opening *.log I tried following commands: :syntax on :set filetype=log4j etc, but log4j-plugin ignores me.
UPDATE2
When app.php, :scriptnames consists:
21: /usr/share/vim/vim74/syntax/php.vim
22: /usr/share/vim/vim74/syntax/html.vim
23: /usr/share/vim/vim74/syntax/javascript.vim
it's ok and i see highlight, but when logs.log - fail..
Try using
log4jhighlighter
The installation details are present in github.
autocmd BufRead,BufNewFile *.log set syntax=log4j
autocmd BufRead,BufNewFile program_log set syntax=log4j
set syntax is wrong at this point try set filetype=log4j
OS: CentOS 5.7
I am trying to get both gVim/Vim have syntax highlight for a new file type. So far I did:
Create syntax file at ~/.vim/ftdetect/foo.vim.
Using Vim can automatically detect the new file type and enable syntax highlighting. $ vim myfile.foo
But gVim doesn't have syntax highlighting.
I tried to add this line in ~/.gvimrc:
au BufRead,BufNewFile *.foo set filetype=foo
But it looks like gVim didn't load ~/.vim/ftdetect/foo.vim at all. How should I configure gVim?
Move the foo.vim to ~/.vim/syntax/ doesn't work for both Vim/gVim. They can't auto detect ~/.vim/syntax folder.
Below are the scriptnames list (+ sign to indicate extra files loaded by gVim), gVim does load foo.vim, but not sure how to figure out what's overwrite the foo.vim settings. Since using :set syntax=foo in gVim won't work either.
:au BufRead,BufNewFile *.foo shows no detection rule for both vim/gVim. So the Vim just magically works...
This is the syntax rule. Is the version checking in the rule file causing gVim can't recognize the *.foo file?
[vim:scriptnames]
1: /etc/vimrc
2: /usr/share/vim/vim70/syntax/syntax.vim
3: /usr/share/vim/vim70/syntax/synload.vim
4: /usr/share/vim/vim70/syntax/syncolor.vim
5: /usr/share/vim/vim70/filetype.vim
6: /home/myusername/.vim/ftdetect/foo.vim
7: /home/myusername/.vimrc
8: /usr/share/vim/vim70/plugin/getscript.vim
9: /usr/share/vim/vim70/plugin/gzip.vim
10: /usr/share/vim/vim70/plugin/matchparen.vim
11: /usr/share/vim/vim70/plugin/netrwPlugin.vim
12: /usr/share/vim/vim70/plugin/rrhelper.vim
13: /usr/share/vim/vim70/plugin/spellfile.vim
14: /usr/share/vim/vim70/plugin/tarPlugin.vim
15: /usr/share/vim/vim70/plugin/tohtml.vim
16: /usr/share/vim/vim70/plugin/vimballPlugin.vim
17: /usr/share/vim/vim70/plugin/zipPlugin.vim
18: /usr/share/vim/vim70/scripts.vim
[GVIM :scriptnames]
1: /etc/vimrc
2: /usr/share/vim/vim70/syntax/syntax.vim
3: /usr/share/vim/vim70/syntax/synload.vim
4: /usr/share/vim/vim70/syntax/syncolor.vim
5: /usr/share/vim/vim70/filetype.vim
6: /home/myusername/.vim/ftdetect/foo.vim
+ 7: /usr/share/vim/vim70/menu.vim
+ 8: /usr/share/vim/vim70/autoload/paste.vim
9: /home/myusername/.vimrc
10: /usr/share/vim/vim70/plugin/getscript.vim
11: /usr/share/vim/vim70/plugin/gzip.vim
12: /usr/share/vim/vim70/plugin/matchparen.vim
13: /usr/share/vim/vim70/plugin/netrwPlugin.vim
14: /usr/share/vim/vim70/plugin/rrhelper.vim
15: /usr/share/vim/vim70/plugin/spellfile.vim
16: /usr/share/vim/vim70/plugin/tarPlugin.vim
17: /usr/share/vim/vim70/plugin/tohtml.vim
18: /usr/share/vim/vim70/plugin/vimballPlugin.vim
19: /usr/share/vim/vim70/plugin/zipPlugin.vim
+ 20: /home/myusername/.gvimrc
+ 21: /usr/share/vim/vim70/colors/torte.vim
22: /usr/share/vim/vim70/scripts.vim
What gets loaded should be identical for Vim and gVim (unless you do crazy stuff like manipulating the 'runtimepath' in your .gvimrc); you can check with :scriptnames whether your syntax detection script got loaded (and then, also the actual syntax/foo.vim syntax script).
Also, :au BufRead,BufNewFile *.foo should list your detection rule.
Does (other) syntax highlighting work in gVim?! If it doesn't, you have a general problem there.