tags:

views:

208

answers:

1

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 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.

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

+3  A: 

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.

Luc Hermitte
Most guards I have seen use a variable called 'loaded_<plugin-name>'.
too much php