Open Source Software Technical Articles

Want the Best of the Wazi Blogs Delivered Directly to your Inbox?

Subscribe to Wazi by Email

Your email:

Connect with Us!

Current Articles | RSS Feed RSS Feed

Three tools for managing Vim plugins

  
  
  

The venerable Vim editor lets you add plugins to enhance features and functionality. The more plugins you add, the greater the challenge you may have managing them, since the standard instructions for installing plugins are not always consistent. Older plugins are downloaded in archived format; you need to extract them to the .vim subdirectory in your home directory and run the command :helptags the next time you start Vim. More recent plugins only need to be moved to ~/.vim/plugin to be available the next time that you start Vim. The second installation method is more orderly than the first, but you need to check which to use each time that you add a plugin. And with either method, you have to update each plugin (or delete it) manually.

If managing Vim plugins gets you in a muddle, you can turn to three tools that can make managing other plugins easier: vim-addons, Pathogen, and Vundle.

vim-addon-manager

vim-addons is a command-line plugin manager that you run outside of Vim. On Debian, Fedora, and Ubuntu and their derivative distributions, you can add it by installing the package vim-addon-manager. On distributions where it is available, you might also want to add vim-scripts, which downloads two dozen popular Vim plugins, thereby letting you manage Vim with the package manager as much as possible.

The vim-addon-manager command follows the basic command with both subcommands and options; for example, vim-addons -v install vim-fugitive installs Vim-fugitive with a verbose description of what is happening. The command uses a registry directory (/usr/share/vim/registry), a source directory for addons (user/share/vim/addons), and a target directory for installation ($HOME/.vim for an ordinary user, /var/lib/vim/addons for all users when you are logged in as root). You can change the default for all these directories by using an option to specify an alternative directory.

To begin using vim-addons, enter vim-addons |less to see a list of all plugins on the system and their status. To install plugins, enter vim-addons install [PLUGIN]. To remove a plugin, use remove as the subcommand. You can use the subcommand disable to make a plugin unavailable from an account, or enable to restore its use.

Pathogen

Rather than a separate utility like vim-addons, our second utility, Pathogen, is a Vim plugin for managing other plugins. Pathogen works with a subdirectory structure that places all the files for each plugin together, unlike the directory structure used by standard Vim. The advantage is that while you must still perform deletions and upgrades manually, Pathogen leaves you in no doubt of what directories and files are involved.

This difference in directory structure raises the possibilty of conflicts. For this reason, before you install Pathogen, remove or rename any .vim directory or .vimrc configuration file in your home folder and replace them with new, empty ones. The new .vim directory must contain the subdirectories autoload and bundle before you install Pathogen.

You can find Pathogen on GitHub.com, which hosts the most complete set of Vim plugins. When the new .vim directory is ready, create a GitHub account and log in to download Pathogen from GitHub to ~/.vim/autoload with one of the following commands. If you use Git, run:

git clone git://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim ~/.vim/autoload/pathogen.vim

If you prefer cURL, run:

curl -k https://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim > ~/.vim/autoload/pathogen.vim

Once you've copied the directory structure to your .vim directory, create a .vimrc file and add the lines:

filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags() "
filetype plugin indent ongit clone git://github.com/tpope/vim-fugitive

These lines ensure that Pathogen is not treated as just another plugin as it loads, and that it starts before any other ones so it can take over plugin management. In addition, they automatically update the help for all plugins managed by Pathogen each time that Vim starts, so you no longer have to worry about manually regenerating it each time that you add a new plugin.

Once Pathogen is installed, adding another plugin is a matter of adding its directory structure. Change to ~/.vim/bundle and download your new plugin from GitHub using the command structure:

git clone git://github.com/[MAINTAINER]/ [PLUGIN PATH] ~/.vim/bundle/[PLUGIN PATH]

or, if you prefer cURL:

curl -k https://github.com/[MAINTAINER]/ [PLUGIN PATH] > ~/.vim/bundle/[PLUGIN PATH]

The next time you start Vim the plugin should be loaded and running. Once you have Pathogen you have no further need for your old .vim and .vimrc files, except as a list of plugins you still need to transfer to Pathogen's management.

If you find a plugin that is incompatible with Pathogen – which is unlikely these days – you're better off trying to find another plugin with similar features than falling back on Vim's standard plugin management. Pathogen's rationalization of plugin management is too useful to discard unless you have no other choice.

Vundle

Our third utility, Vundle, refers to plugins as bundles, and is short itself for "Vim bundle." All plugins that work with Pathogen also work with Vundle, and Vundle has all the advantages of Pathogen – but in addition, Vundle provides automatic updates of plugins, as well as utilities that provide features similar to those available through vim-addons.

Vundle is located at /gmarik/vundle on Github. Unlike Pathogen, Vundle should be placed in ~/.vim/bundle, the same as any other plugin that it is to manage. To work, it requires the same directory structure as Pathogen, plus the following lines in .vimrc:

set nocompatible             
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
filetype plugin indent on  

You can add other plugins, one per line, below the line for Vundle (for example, Bundle 'tpope/vim-fugitive'). Each plugin listed will be updated automatically each time you start Vim.

Neobundle
In the last couple of years, a fourth plugin manager called Neobundle has emerged. Neobundle is essentially a rewrite of Vundle with a change of names, with Vundle's :BundleClean utility, for example, being replaced by Neobundle's :NeoBundleClean. But it includes additional features that go far beyond plugin management. Idiosyncratic, diverse, and apparently under rapid development, Neobundle is currently not an alternative I would recommend, especially to those dependent on the English translations of its Japanese documentation.

Installing Vundle also enables four utilities that you can use from within Vim:

  • :BundleList: Lists configured plugins
  • :BundleInstall [PLUGIN]: Installs or updates plugins
  • :BundleSearch [PLUGIN]: Searches for a plugin
  • :BundleClean [PLUGIN]: Removes plugins with manual confirmation or auto-approve.

Run :BundleInstall without specifying any plugins the first time you open Vim with Vundle, and every time after you add a plugin.

Which to choose?

So which of the three alternatives should you use?

vim-addons-manager has the advantage of using package management, which means that all – or at least most – of the additions to your system are under one system, especially if you content yourself with the plugins available in vim-scripts. If you are familiar with Debian- or Ubuntu-specific tools such as apt-get, this utility's command structure should be immediately familiar. In addition, vim-addons is better suited than Pathogen or Vundle for installing plugins for all users rather than for individual accounts.

As for Pathogen or Vundle, at first you might choose Vundle because of its larger feature set. However, if you are security-conscious, you might have second thoughts about whether you want automatic updates. The problem is not so much that the updates make Vim start more slowly – you would need dozens of plugins for that to be a problem – so much as you prefer to know when the system changes.

You might also decide that having to edit .vimrc each time you add a plugin to Vundle cancels out at least some of the advantage of automatic updates. Checking the directory structure of ~/.vim/bundle from the command line while running Pathogen is really no more difficult than running Vundle's utilities within Vim. In fact, you might find running Pathogen easier because you are already familiar with basic commands like ls and rm, and don't need to learn new ones.

In other words, the choice depends on what you are used to and how you prefer to work. Any of the three is more efficient than relying on unmodified Vim's options, and you can easily switch to another if one fails to suit you.




This work is licensed under a Creative Commons Attribution 3.0 Unported License
Creative Commons License.

Comments

You wrote a useful and informative article. 
 
For administrators, Vim addon manager offers central control for offering plug-ins. Plug-in management is simplified for both administrators and users with this. But for plug-ins not under the management of the Vim addon manager, Vim users will find that either Pathogen or Vundle offers huge advantages over the scatter-to-the-wind default for Vim plug-in installation and returns sanity to Vim plug-in removal: rm -Rf ~/.vim/bundle/plug-in-directory. 
 
The ease of plug-in removal should not be underestimated. I often want to try a newly-found plug-in. Before I used Pathogen, I felt resistance to the idea of installing a new plug-in as I considered the possibility of having to later remove the plug-in if it proved unsuitable. Plug-in removal can involve much detective work in tracking down a plug-in's various files in multiple subdirectories of ~/.vim. Pathogen and Vundle eliminate the problem by recreating those directories within each plug-in's bundle directory. Simply delete the plug-in's directory from the bundle directory, and the entire plug-in will be gone. 
 
My .vimrc is less cluttered because of Pathogen. I still have leftover plug-in settings that need to be cleaned out, though. Perhaps there is a solution for that problem that I have not yet discovered. 
Posted @ Saturday, February 02, 2013 11:20 AM by Scott
Is there a way to use a tool to manage vim plugins and update them, while still being able to change them and not loose modifications you could have done into these plugins (for example custom snippets... ) ?
Posted @ Friday, July 05, 2013 7:36 AM by PA
The problem with that idea is that any tool used would need to not only know which changes were yours, but be able to prevent upstream updates from overwriting your customizations. You could use a version control system, such as Git, but you would have to maintain separate repositories of files for the same plug-ins. I doubt if there is logic available that can blend files in the manner you suggest. If you were only changing ancillary files, like snippets, you could succeed by just restoring your custom versions, but modifying the code of the plug-ins themselves would be problematic if you wanted your customizations to survive an update. Your best bet would be to submit your customizations to the plug-in author and hope they merge your changes with their code. 
Posted @ Friday, July 05, 2013 9:51 AM by Scott
Also, the use of handbags appropriately can advice adumbrate assertive flaws. For example, an colossal backpack would plan best for fendi outlet taller woman, aback the bag will accomplish her attending smaller, while a baby backpack would maker her attending bigger than she already is. But, of course, this would alone plan if the accepting application the backpack knows how to mix and bout the backpack according to her physique admeasurement and her outfit. Blush and designs aswell play a allotment here, aback there may be assertive designs that would belie what the accouterments of the woman is aggravating to do. When acclimated properly, these accoutrements can be woman is best friend. And with artist aggressive handbags and broad replica handbags, you no best acquire to absorb a abounding bulk of gucci replica money aback these items are cheaper compared to their artist counterparts. Afterwards all, as the items aloft acquire demonstrated, you do not acquire to use big-ticket handbags to accomplish the accomplished attending assume apt. Many humans may anticipate that artist aggressive handbags and broad replica handbags won not plan as abundant accessories because they are alone imitations of the absolute thing. However, what you should bethink is that the action of the backpack does not depend on the bulk or the designer it depends on what you use and how you use it. These types of dior replica bags, if acclimated properly, can accompany out your inner, a lot of hidden beauty. No bulk how big-ticket a artist backpack is, it cannot accomplish this if it is not acclimated properly. Broad replica handbags and broad artist aggressive handbags can be your best actualization accessory. Analysis out website that acquaint broad replica handbags and broad artist aggressive handbags to apperceive added on how you can about-face these accepted handbags into the best actualization accessory! Hand accoutrements are the capital accessories for the women replica louis vuitton as this being can add the breeding and adorableness in their outlook. The trend of application handbags is ascent to the aiguille akin from the time if the celebrities accept been traveling to backpack the gucci replica beautiful and branded accoutrements with them.
Posted @ Friday, September 12, 2014 3:46 AM by Heaity
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics