How do you disable a specific plugin in Vim?

后端 未结 2 359
伪装坚强ぢ
伪装坚强ぢ 2021-02-03 23:37

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.

In my .vimrc I have a sections

相关标签:
2条回答
  • 2021-02-04 00:12

    Most plugins have a (re)inclusion guard.

    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.

    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.

    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.

    0 讨论(0)
  • 2021-02-04 00:16

    Add this line to your .vimrc

    let g:loaded_nerdtree_exec_menuitem = 1
    
    0 讨论(0)
提交回复
热议问题