Vim 加载 vimrc 后是否加载插件? [英] Does Vim load plugins after loading vimrc?

查看:22
本文介绍了Vim 加载 vimrc 后是否加载插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖插件中的突出显示设置.该插件执行此操作:

突出显示!链接 WordUnderTheCursor 下划线

首先,我不知道添加到 highlight! 会做什么.但这无关紧要.

在 vimrc 中做这样的事情

highlight clear WordUnderTheCursor突出显示 WordUnderTheCursor cterm=粗体 ctermfg=254 ctermbg=160

似乎不影响行为.

只有当我在vimrc中直接修改Underlined样式(感觉不对)时,修改才生效.

这是否证明插件正在运行后运行vimrc?

如何取消样式的链接?我真的不知道这是否只是插件做了一些创造性和不受支持的事情,或者这是否是 Vim 的正常行为.

解决方案

是的.vimrc 在插件之前加载.

如果您查看 :h 初始化,您会发现该步骤3 是加载 vimrc,步骤 4 是加载插件.

您还可以通过查看 :scriptnames 的输出看到 vimrc 在插件之前加载.scriptnames 按照它们的来源顺序列出所有来源的脚本,vimrc 是第一个来源.(看看:h :scriptnames).

<小时>

要修复突出显示,您只需要在插件获取后运行突出显示命令.为此,您将文件放在 .vim 目录的 after 目录中.(看看:h after-directory)

所以创建文件.vim/after/plugin/hicursorwords.vim,内容如下

highlight clear WordUnderTheCursor突出显示 WordUnderTheCursor cterm=粗体 ctermfg=254 ctermbg=160

这将导致在您更改插件设置之前获取插件.

(当然前提是你不想编辑插件)

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. But that's irrelevant.

Doing stuff like this in the 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.

Is this proof that the plugin is being run after the vimrc runs?

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.

解决方案

Yes. vimrc is loaded before plugins.

If you look at :h initialization you will find that step 3 is load vimrc and step 4 is load plugins.

You can also see that vimrc is loaded before plugins by looking at the output of :scriptnames. scriptnames lists all sourced scripts in the order they were sourced and vimrc is the first thing sourced. (Take a look at :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. (Take a look at :h after-directory)

So create the file .vim/after/plugin/hicursorwords.vim with the following contents

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)

这篇关于Vim 加载 vimrc 后是否加载插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆