你如何禁用 Vim 中的特定插件? [英] How do you disable a specific plugin in Vim?

查看:53
本文介绍了你如何禁用 Vim 中的特定插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Vim 设置为使用出色的 NERDTree 插件.但是,在某些环境中,我不希望加载此插件.

I have Vim set up to use the excellent NERDTree plugin. However, there are some environments where I do not want this plugin to be loaded.

在我的 .vimrc 中,我有一个部分只在特定环境变量为真时运行.在其中一个部分中,我想禁用 NERDTree 的加载,但我遇到的所有信息都说明了如何禁用所有插件,而不仅仅是一个.

In my .vimrc I have a sections that are only run when specific environment variables are true. In one of these sections I would like to disable the loading of NERDTree but all of the information I've come across states how to disable all plugins, not just one.

有人可以演示如何在 Vim 中禁用加载特定插件吗?

Could someone demonstrate how to disable the loading of one specific plugin in Vim?

推荐答案

大多数插件都有(重新)包含保护.

Most plugins have a (re)inclusion guard.

打开插件,看守卫的名字,如果有的话(如果没有,自己加一个,联系作者让他修复他的插件),最后在你的.vimrc中将其值设置为1.仅此而已.

Open the plugin, see the name of the guard, if any (if not, add one by yourself, and contact the author to make him fix his plugin), and finally set its value to 1 in your .vimrc. That's all.

我不能更具体地说明打开并寻找守卫",因为并非所有插件都使用相同的守卫命名策略.不过通常是 g:loaded_pluginname.

I can't be more specific as "open, and look for the guard" as not all plugins use the same guards-naming policy. It's often g:loaded_pluginname though.

关于 ftplugins,它变得更加棘手.守卫是一个缓冲区局部变量.因此,它不能在您的 .vimrc 中指定(因为它仅适用于您打开的第一个缓冲区).最简单的方法是将您的 ftplugin 从 .vim/ftplugin 移动到 .vim/after/ftplugin,并在 ftplugin 中将相关的反重新包含保护设置为 1在你的非后层次结构中.只要 ftplugin 不希望放在 after/ 中(或者相反,应该没问题).注意:大多数 ftplugins 认为它​​们是独一无二的,并且(错误地)使用变量 b:did_ftplugin 作为重新包含保护.

Regarding ftplugins, it becomes more tricky. The guard is a buffer-local variable. As such, it can't be specified into your .vimrc (as it would apply only to the first buffer you open). The easiest way would be to move your ftplugin from .vim/ftplugin to .vim/after/ftplugin, and to set the relevant anti-reinclusion guard to 1 in a ftplugin in your non-after hierarchy. As long as the ftplugin does not expect to be placed in after/ (or the contrary, it should be fine). Note: most ftplugins believe they are unique and (mis-)use the variable b:did_ftplugin as reinclusion guard.

这篇关于你如何禁用 Vim 中的特定插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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