How to manage Vim plugins

Vim is a versatile, lightweight text editor on Linux. While its initial learning curve can be overwhelming for an average Linux user, its benefits are completely worthy. As far as the functionality goes, Vim is fully customizable by means of plugins. Due to its high level of configuration, though, you need to spend some time with its plugin system to be able to personalize Vim in an effective way. Luckily, we have several tools that make our life with Vim plugins easier. The one I use on a daily basis is Vundle.

What is Vundle?

Vundle, which stands for Vim Bundle, is a Vim plugin manager. Vundle allows you to install, update, search and clean up Vim plugins very easily. It can also manage your runtime and help with tags. In this tutorial, I am going to show how to install and use Vundle.

Installing Vundle

First, install Git if you don't have it on your Linux system.

Next, create a directory where Vim plugins will be downloaded and installed. By default, this directory is located at ~/.vim/bundle

$ mkdir -p ~/.vim/bundle

Now go ahead and install Vundle as follows. Note that Vundle itself is another Vim plugin. Thus we install Vundle under ~/.vim/bundle we created earlier.

$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Configuring Vundle

Now set up you .vimrc file as follows:

set nocompatible              " This is required
filetype off                  " This is required

" Here you set up the runtime path
set rtp+=~/.vim/bundle/Vundle.vim

" Initialize vundle
call vundle#begin()

" This should always be the first
Plugin 'gmarik/Vundle.vim'

" This examples are from https://github.com/gmarik/Vundle.vim README
Plugin 'tpope/vim-fugitive'

" Plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'

"Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'

"git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'

" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}

" Avoid a name conflict with L9
Plugin 'user/L9', {'name': 'newL9'}

"Every Plugin should be before this line

call vundle#end()            " required

Let me explain the above configuration a bit. By default, Vundle downloads and installs Vim plugins from github.com or vim-scripts.org. You can modify the default behavior.

To install from Github:

Plugin 'user/plugin'

To install from http://vim-scripts.org/vim/scripts.html:

Plugin 'plugin_name'

To install from another git repo:

Plugin 'git://git.another_repo.com/plugin'

To install from a local file:

Plugin 'file:///home/user/path/to/plugin'

Also you can customize others such as the runtime path of you plugins, which is really useful if you are programming a plugin yourself, or just want to load it from another directory that is not ~/.vim.

Plugin 'rstacruz/sparkup', {'rtp': 'another_vim_path/'}

If you have plugins with the same names, you can rename you plugin so that it doesn't conflict.

Plugin 'user/plugin', {'name': 'newPlugin'}

Using Vundle Commands

Once you have set up you plugins with Vundle, you can use it to to install, update, search and clean unused plugins using several Vundle commands.

Installing a new plugin

The PluginInstall command will install all plugins listed in your .vimrc file. You can also install just one specific plugin by passing its name.

:PluginInstall
:PluginInstall <plugin-name>

Cleaning up an unused plugin

If you have any unused plugin, you can remove it by using the PluginClean command.

:PluginClean

Searching for a plugin

If you want to install a plugin from a plugin list provided, search functionality can be useful.

:PluginSearch <text-list>

While searching, you can install, clean, research or reload the same list on the interactive split. Installing plugins won't load your plugins automatically. To do so, add them to you .vimrc file.

Conclusion

Vim is an amazing tool. It can not only be a great default text editor that can make your work flow faster and smoother, but also be turned into an IDE for almost any programming language available. Vundle can be a big help in personalizing the powerful Vim environment quickly and easily.

Note that there are several sites that allow you to find the right Vim plugins for you. Always check http://www.vim-scripts.org, Github or http://www.vimawesome.com for new scripts or plugins. Also remember to use the help provider for you plugin.

Keep rocking with your favorite text editor!

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.

Christopher Valerio

Christopher works as a sysadmin for an American company in Costa Rica. He is a Linux enthusiast and Archlinux Lover. When he is not typing commands, he is spending time with his wife and kids or reading some cool book.

Latest posts by Christopher Valerio (see all)

2 thoughts on “How to manage Vim plugins

  1. As someone who doesn't write code, but who's willing to learn, I'm curious as to why the regular "terminal" that came with my distro isn't good enough? Is it that Vim comes with a certain color scheme? Or are there testing tools for when you write code?...I dunno it just seems like its non-essential as to which Text Editor you use. Or am I wrong? (Remember, I'm still trying to just LEARN Python and Ruby!) so I don't have a veteran's eye for these kinds of things !!

  2. in the tutorial "how to turn VIM into a full-fledged IDE" there is the suggestion to install pathogen as plugin manager. may you expand on the differences between pathogen and vundle? which one is the most recommended for basic users?

Leave a comment

Your email address will not be published. Required fields are marked *