Vim : Welcome To The Vundle

Today we are going to talk about Vim. Again…
Vim is your text editor, Vim is your IDE, Vim is everything you need to develop you masterpiece applications. You are skeptical? It is normal. You are used to your comfortable IDE, you are used to click navigation, auto-complete and beautiful menus, why are you going to leave all of that for the dark black window of Vim? Why you use linux/mac instead of windows, why you use chrome/firefox instead of internet explorer, why you are opening you terminal at all… Because you are developer, you want to have control over the things you do and not vice versa…

Vim is not just a text editor, it can be extended by plugins. And yes I know that you think that means putting strange files at strange places and waiting for the magic to happen after the restart.

Vim has a plugin that does the plugin management for you. It is called Vundle. It has alternatives and I’ll talk about them some sunny day, but for now let’s talk about Vundle.

You can go to the its github site – https://github.com/gmarik/vundle. There you’ll find instructions  for installing and using it. But I’m going to explain some of these instructions to you, so:

  1. Go to your $HOME/.vim folder (cd ~/.vim).
  2. Create a folder called bundle, if it doesn’t already exist (mkdir bundle).
  3. Navigate to the bundle directory (cd bundle).
  4. If you don’t have git, install it (sudo apt-get install git / brew install git). Execute the following command:
    git clone https://github.com/gmarik/vundle.git
  5. Vundle is downloaded. Now edit your vimrc file (vim ~/.vimrc).
     set nocp                       " Vim is not Vim if it is Vi compatible
     filetype off                   " required!
    
     set rtp+=~/.vim/bundle/vundle/
     call vundle#rc()  
     Bundle 'gmarik/vundle' 
     filetype plugin indent on     " required!
  6. Now save the file and exit. Lets examine the vimrc script.
    – The first two line make so that Vim can handle working with Vundle; We should be VIm, not Vi and the FileType event will be turned off for now.
    – The third line adds the Vundle plugin to the runtime path.
    – The fourth line turns on Vundle, by calling the ‘rc’ function defined in the plugin.
    – From here on, we can add bundles using the Bundle command.
    – After all the bundles (plugins) are listed we turn on the FyleType event again. But with this particular command we tell vim to load the plugins located in the ftplugin directories related to the file type of the file we open for editing.
  7. You can add bundles for plugins located at github by adding Bundle ‘<user>/<project>’
  8. You can add bundles in normal no-github repositories by adding Bundle ‘<url>’
  9. You can add the bundles from the https://github.com/vim-scripts repository with
    Bundle ‘<plugin_name>’
  10. :BundleInstall – installs all the Bundles specified in your vimrc that are not already installed.
  11. :BundleInstall! – installs all the Bundles specified in your vimrc that are not already installed and updates these which are installed but can be updated.
  12. :BundleList – lists all the bundles that are installed.
  13. :BundleSearch – can be used to list all the known bundles or to search for bundles using a search phrase.

If you decide to use vim as your primary text/source code editor, you should try Vundle. Later in various posts I’ll use different Vim plugins, that you can easily install using Vundle.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s