Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you disable a specific plugin in Vim?

Tags:

vim

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?

like image 547
Zxaos Avatar asked May 22 '10 17:05

Zxaos


People also ask

How do I disable Vim plugins?

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.

How do I enable plugins in Vim?

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.

How do I uninstall Vim Vundle plugins?

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.


1 Answers

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.

like image 131
Luc Hermitte Avatar answered Sep 26 '22 02:09

Luc Hermitte