If you are an avid Vim user, you know that the one thing that is lacking is a good plugin management system. With the default vim installation, plugins are scattered through various folders in your .vim folder and its a nightmare to enable/disable or remove plugins once you have installed them. There are numerous tools out there that claim to make plugin management easier, but frankly, I haven’t tried any of them since they all seem to involve having to install a separate tool to do the task. But this neat plugin by Tim Pope called Pathogen, is a little different. It uses vim itself to mange the plugins properly. With Pathogen, plugin management is now a breeze.
Pathogen basically modifies the vim runtime paths which tell vim where to find plugins. The standard directory used by Pathogen to install vim plugins is .vim/bundle. When used appropriately (with the correct line of code in your vimrc) Pathogen looks for a bundle folder in .vim and adds the subdirectories of it to the runtime path. This essentially means each subdirectory of bundle looks like a .vim/ folder to vim.
Taking the plugin fuzzyfinder as an example, the following table shows the path translations
.vim/bundle/fuzzyfinder/doc » .vim/doc/
.vim/bundle/fuzzyfinder/plugin » .vim/plugin
.vim/bundle/fuzzyfinder/autoload » .vim/autoload
This makes using Pathogen and Vim plugins really easy. All you have to do to install a plugin is to get the plugin from wherever, and put it in its own folder in ..vim/bundle To remove the plugin, just delete the folder from .vim/bundle. You can even use symlinking techniques as used in many Linux programs to mange their configuration files. Create a .vim/bundle-available folder, put all the plugins in there and create symlinks from .vim/bundle pointing to the corresponding plugin in .vim/bundle-available.
There are a few things to note for the proper operation of Pathogen. The folder that you create inside .vim/bundle would need to have the proper subdirectory organization depending on what types of files the plugin contains. That is, you can’t just drop the .vim file in the main folder of the plugin. If the file a is a plugin type, it needs to go to the plugin folder, if it’s an autoload type, it needs to go the “autoload” folder. To continue with our fuzzyfinder example, this plugin has a file called fuf.vim in its plugin(.vim/bundle/fuzzyfinder/plugin/) folder. If we placed this fuf.vim file in the main fuzzyfinder folder (.vim/bundle/fuzzyfinder/fuf.vim) , the plugin will not work properly since it will look just like .vim/fuf.vim to Vim. Moreover, don’t make the mistake I made and name the bundle folder “bundles”, it won’t work.
The proper usage instructions for Pathogen can be found on the plugin’s page http://www.vim.org/scripts/script.php?script_id=2332. But to summarize:
- Install Pathogen by putting pathogen.vim in .vim/autoload folder.
call pathogen#runtime_append_all_bundles()to your .vimrc
- Create a .vim/bundle and put your plugins it. Each plugin needs its own folder.