Vim plugins the easy way

2014-08-29    Filed under linux, Tags vim

When Vim plugins are installed the standard way, all files that belong to different plugins get mixed together in the .vim directory. This makes very difficult to keep the system clean and updated, or to remove a given plugin.

There are various solutions to avoid this problem and keep each plugin's files in separated directories. The most popular are Pathogen and Vundle.

I like Pathogen more, because it allows to install a plugin from command line without editing any configuration file (no need to touch vimrc except for optional customization). To remove a plugin only takes to remove de plugin's directory, so easy.

The only drawback is you have to update your plugins manually.

How to install Pathogen

You can follow the directions from this blog, or just follow these simple steps. In the end, the trick is that Pathogen will be the only plugin installed "normally" in its standard directory (autoload):

mkdir -p ~/.vim/autoload ~/.vim/bundle
cd ~/.vim/autoload
wget http://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim

Then edit ~/.vimrc so this plugin will load all the other when Vim starts:

call pathogen#infect()
call pathogen#helptags()

Pathogen will search for the plugins in ~/.vim/bundle.

Installing plugins with Pathogen

You can get the plugins from vim.org and unzip them in ~/.vim/bundle, but it is easier to download them from Github (most of them are available this way). Also, this is better to keep them updated easily. You can search for available plugins at Github in the vim scripts site.

For example, to install the plugin vim-gnupg you can get it from vim.org here or from Github here. To download the plugin from Github:

cd ~/.vim/bundle
git clone https://github.com/jamessan/vim-gnupg.git

With Github you can use Git protocol or HTTPS. Git protocol is more efficient but some firewalls block its port.

You can edit ~/.gitconfig to force Git to always use HTTPS standard port. Add this to the file:

[url "https://github"]
    insteadOf = git://github

These are some plugins I like:

cd ~/.vim/bundle
git clone git://github.com/vim-scripts/Colour-Sampler-Pack
git clone https://github.com/firat/vim-bufexplorer
git clone git://github.com/fholgado/minibufexpl.vim.git
git clone https://github.com/Rykka/riv.vim.git
git clone https://github.com/jamessan/vim-gnupg
git clone https://github.com/vim-scripts/taglist.vim