Vim Plugins

Vim has been the go-to Linux terminal window editor since 1991 when it came along as an improved Vi.  One of the things that Vim improves over Vi is its ability to configure the editor and add third party plugins.  We talked about some of the built-in configuration options you can add to the .vimrc file in my Vim Configuration post.  In this article, we'll limit ourselves to Vim plugins.

The NERDTree plugin with the help screen open

 

Vim plugins offer additional functionality to the Vim editor that could not be created with a simple .vimrc set option.  There are quite a few plugins for Vim, and we'll review the most popular shortly.  You can find information about plugins on the Vim web site under scripts.  There are some 3,799 Vim plugins at this writing.  Chances are you can find, and add, the functionality you want in one of these plugins.

These plugins are written in a language called "vimscript".  Vimscript files end with a ".vim" suffix.  Plugin installation varies slightly from one plugin to another, but for the most part installation is farily standard and simple.  In your home diretory, you'll find a .vim directory.  In the .vim directory, you will create, or there is already, a plugin directory. ~/.vim/plugin.  Your ".vim" plugin files will go here.  Any documentation will go into ~/.vim/doc, and are usually just .txt files.

When Vim starts up, it looks in the ~/.vim/plugin directory. and any .vim files it finds there, it loads automatically, piece of cake.  Each plugin will have a slight learning curve to figure out how to use it.  This is usually found in the documentation.

When you find a plugin you like, you can "google" it, and find the script page on the Vim web site. The instruction for each plugin is in a standard format that will answer most of your questions.  You will usually find a .zip file that you can download, extract the files, and copy them to the appropriate .vim subdirectory.

A word to the wise, chances are they'll be a github page for the vim plugin you want to download, you can clone the plugin from github.  I recommend using github over the vim web site, because the plugins are more up to date on github, and they install easier.  If you don't have git installed on your computer yet, see my articles on git to get you started.

Go to your home directory and run git clone.  The command to get the plugin from github usually goes something like this: "git clone http://github.com/scrooloose/nerdtree.git" and that's it.  Git installs the plugin with appropriate directories for you without the extraction and downloading from the vim website, much easier, and more up to date.  Git will usually create a directory for the download, inside the directory, you'll find the .vim subdirectories.  Copy these to ~/.vim and your plugin is installed, and your all set.

There are a lot of good articles on the Internet on each plugin.  However, I would like to give a special shout out to a series of YouTube videos on Vim Essential Plugins put out by nettuts+.  Each video shows you how to install the plugin, and how to use it.  Watching the plugin video is the quickest way to get up and running with a Vim plugin. Kudos, good stuff.

Out of the some 3,799 plugins, which are the plugins people use the most, and you should consider trying out?

I've included a link to the web page in the plugin name, and the link to the YouTube video on the plugin when available.  You can also find additional written articles on Vim plugins if you search by the plugin name.

NERDTree - An explorer window for your vim editor with bookmarks.  The most installed plugin, ever.  Type "?" in the NERDTree window to see the Help screen in the first picture above.  If you look at my .vimrc file in the picture below, you'll see I've mapped the F2 key to open NERDTree and the F3 key to close the explorer window. Cool.   I highly recommend this plugin.    The NERDTree video.

Mapping Hot Keys to open and close NERDTree in my Vimrc file

 

SnipMate - A code snippet library that you use to "tab" code snippets into the file your editing.  You can create you own snippets by editing the file.  A snippet file is shown on the right in the below picture.  The SnipMate Video 

SnipMate snippet library files with a file open on the right using NERDTree

 

NERDcommenter - Quickly comment and un-comment blocks of code with tags determined by whatever language is open in the editor.

MRU - "Most Recently Used" Open recently edited files.

Matchit - Jump to the matching word or tag in a file.

Bufexplorer - Quickly switch between open buffer windows, and edit several files in a single editor session.

Project - Set up a list of files that your working with in a project that stay on the left side of the editor window for quick access.

Align - Align the equal signs and other symbols in your file for easier reading.

Taglist - A source code browser that creates lists of classes, methods, functions in your code for quick access.

There are many more language specific plugins that will help you with your coding, and there are color themes available, along with color sampler plugins for coloring language syntax.  I think this gives you a flavor for what Vim plugins can do for your Vim editor.  All you have to do is give a couple of plugins a try, and you'll be hooked on getting your Vim editor just the way you want it.  Enjoy.

Comments are closed.