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?
On the begin of the script file find something Like if exists('g:vimacs_is_loaded")... . Then set this variable in your . vimrc or while start vim with vim --cmd "let g:vimacs_is_loaded = 1" . Show activity on this post. This way, whenever I want to open a file with snippets disabled, it is easy.
Starting with Vim version 8, you can install plugins without the need for a package manager by using the default package management tool. You can place Vim plugins in the ~/. vim/pack/vendor/start/plugin_name directory. Note that the plugin_name folder name will vary from plugin to plugin.
Uninstall plugins If you wish to uninstall one of theme, just move the cursor to correct line, and press D . After that, remove the corresponding plugin line in . vimrc file to completely uninstall the plugin from the system.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With