简体   繁体   English

加载vimrc之后,Vim是否会加载插件吗?

[英]Does Vim load plugins after loading vimrc?

I'm trying to override the highlight set in a plugin. 我正在尝试覆盖插件中的突出显示设置。 The plugin does this: 该插件可以执行以下操作:

highlight! link WordUnderTheCursor Underlined   

Firstly, I'm not aware that ! 首先,我不知道! added to highlight does anything. 添加以highlight任何内容。 But that's irrelevant. 但这无关紧要。

Doing stuff like this in the vimrc 在vimrc中做这样的事情

highlight clear WordUnderTheCursor                             
highlight WordUnderTheCursor cterm=bold ctermfg=254 ctermbg=160

Does not appear to affect the behavior. 似乎不影响行为。

Only when I directly modify the Underlined style (which feels wrong) in the vimrc, does the change apply. 仅当我直接在vimrc中修改带Underlined样式(感觉不对)时,更改才适用。

Is this proof that the plugin is being run after the vimrc runs? 是否证明插件在vimrc运行正在运行?

How might I unlink the style? 如何取消样式的链接? I can't really tell if this is just the plugin doing something creative and unsupported, or if this is normal Vim behavior. 我真的不能说这仅仅是插件做些有创意且不受支持的事情,还是这是正常的Vim行为。

Yes. 是。 vimrc is loaded before plugins. vimrc在插件之前加载。

If you look at :h initialization you will find that step 3 is load vimrc and step 4 is load plugins. 如果查看:h initialization您会发现第3步是加载vimrc,第4步是加载插件。

You can also see that vimrc is loaded before plugins by looking at the output of :scriptnames . 通过查看:scriptnames的输出,您还可以看到vimrc已在插件之前加载。 scriptnames lists all sourced scripts in the order they were sourced and vimrc is the first thing sourced. scriptnames列出了所有源脚本的顺序,而vimrc是源头。 (Take a look at :h :scriptnames ). (看看:h :scriptnames )。


To fix the highlighting you just need to run the highlight commands after the plugin gets sourced. 要解决突出显示问题,您只需在获取插件后运行突出显示命令。 To do this you put files in the after directory of your .vim directory. 为此,请将文件放在.vim目录的after目录中。 (Take a look at :h after-directory ) (看看:h after-directory

So create the file .vim/after/plugin/hicursorwords.vim with the following contents 因此,使用以下内容创建文件.vim/after/plugin/hicursorwords.vim

highlight clear WordUnderTheCursor                             
highlight WordUnderTheCursor cterm=bold ctermfg=254 ctermbg=160

This will cause the plugin to be sourced before you change the settings of the plugin. 这将导致在更改插件设置之前先获取插件。

(This of course assumes you don't want to edit the plugin) (这当然是假设您不想编辑插件)

Besides scriptnames , to see what order vim runs things in on startup, you can also use: 除了脚本名 ,要查看vim在启动时按什么顺序运行,您还可以使用:

vim --startuptime <file>

so it will log all the tasks it does in order, and how much time each one takes. 因此它将记录其按顺序执行的所有任务以及每个任务花费的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM