domingo, 6 de marzo de 2011

My Vim configuration. Part 2 - Vim plugins

I was supposed to talk about shortcuts in Vim, but I've changed my mind :P I'm going to talk about how to install plugins for Vim :)

Vim plugins
Vim has a lot of plugins, a lot :D So, how do I choose the plugins I need? Well, fist of all, you have to know what you need. This is very important, you shouldn't use a plugin if you're not sure about why you need it!

Once you've decided which plugins do you want you only need to install them!

How to install a vim plugin
Vim plugins are just scripts and to install them you only need to copy the script file in the right directory. Ok, this looks very similar to the way we add color schemes to our Vim, doesn't it? Yes, the only thing we need to change is the directory. When we install a plugin, we have to add the script file to the 'plugin' (or 'ftplugin' if it is a file-type-dependent script) directory in our .vim directory. Sooo easy :D

Yes, so easy. But, do I have to do that every time I get a new plugin or every time I update an old one? Cannot this process be automated? Yes, it can! There are a lot of tools to manage your plugin dependencies. I am using Vundle right now.

Vundle
Vundle is a plugin management tool for vim. It is very easy to set up and it is very easy to use. You only need to follow their instructions to "install" it. Once you have everything in its right place, you have to add those two lines to your .vimrc file:

This makes bundle available while you're using Vim :D

Vim plugins
Ok, so, how do I install plugins with Vundle? You only need to add the plugins you want to your .vimrc file (with the Vundler format). I have those:

As you can see, you can ask for the plugin by its "official" name or you can linked it to its github repository.

Once you've defined the plugins you want you only need to type:

on Vim to install or update your plugins :D

Ok, that's all for today. Soon on your screens "How to create shortcuts with Vim" (Although maybe I'll talk a little bit about why I choose those plugins)

3 comentarios:

  1. Again, really good post. I'll give a look to the plugins you're using.

    Instead of vundle, which I didnt' know about, I've been using pathtogen [https://github.com/tpope/vim-pathogen] for a while. It's nice, but doesn't install the plugins for you. Maybe I'll give vundle a try.

    ResponderEliminar
  2. Great review!
    Thanks for using Vundle!)

    ResponderEliminar
  3. @jacegu Thanks, mate! I started using pathogen, too, but I find Vundle much more easy to use :D

    @gmarik Thank you for Vundle :D

    ResponderEliminar