How to organize the Vim plugins?

I am a big fan of the Vim editor for many years. However installing, updating and removing Vim plugins require a great deal of time and effort. In this article I would like to introduce a couple of tools, which makes the whole process a breeze. The basic idea is instead of copying plugin files to different directories, just leave them where they are and load them when Vim starts. To remove a plugin, simply delete the corresponding subdirectory.

Prerequisites

  • Vim Editor Version 7.0 or higher(Some plugins won’t work with older vim versions)
  • Ruby
  • Git

The last two applications are part of the xCode bundle.

  1. Before we start, it is probably a good idea to create a backup of the old plugins.
    Backup the .vimrc file

    cp .vimrc .vimrc_backup
  2. Backup the .vim folder
    mv .vim .vim_backup
  3. Create “bundle” subfolder within .vim folder.
    mkdir -p .vim/bundle

    (This is where all the plugin directories will be copied)

  4. Download the pathogen plugin from https://github.com/tpope/vim-pathogen/
    cd .vim

    (navigate to .vim directory)

    git clone git://github.com/tpope/vim-pathogen.git

    (This will download the latest pathogen plugin)

    cp -r ~/.vim/vim-pathogen/autoload ~/.vim/

    (This will copy the autoload directory to .vim folder)

  5. To load pathogen when vim starts, add the following lines in .vimrc
    vim ~/.vimrc

    call pathogen#runtime_append_all_bundles()
    call pathogen#helptags()
    filetype plugin indent on

  6. Remove the vim-pathogen folder.
    rm -rf ~/.vim/vim-pathogen

    (remove the empty folder)

  7. The next step is to download all your favourite plugins into the bundle directory and keep them sync with the latest updates. The Ruby script written by Tammer Saleh comes in handy for this purpose. Once you customize the script by including all the plugins you want to use, all you have to do is to run the script in regular intervals.
  8. Download the latest Ruby script to .vim directory.
    The modified ruby script can be downloaded here.
  9. Open the script and activate your favourite plugins. You can also add new plugins from git, mercurial repositories or even zipped bundles from Vim.org. Once you are ready with the activated collection save the script and run to install.
    ruby update_plugins

You can find my own vim setup on GitHub. Download the complete package and customize it as necessary. Please read the README for installation instructions.

Links

  1. Tim Pope’s pathogen: http://www.vim.org/scripts/script.php?script_id=2332
  2. Ruby script(Tammer Saleh): https://gist.github.com/593551
Be Sociable, Share!
Categories: Tips & Tricks, Unix