Stop Being Scared of Vim


Vim's reputation is that it is extremely powerful once you learn it, but the learning curve is so steep, it's essentially a discontinuity. This is obviously hyperbole, but I would say it's more exaggeration than truth. Vim is certainly harder to learn compared to popular mouse-driven editors like Microsoft Word, Geany, or Eclipse's editor - but it also much more powerful and much faster (note that here, by 'faster', I mean it can make you much more productive; yes, I really do believe that).

I think the real problem is that Vim is intimidating. If you aren't already comfortable in a keyboard-driven editor, opening up a file in Vim and attempting to be productive is somewhat like being dropped into a stick-shift car, having never driven a car before, and being expected to make it to the top of Divisadero St in San Francisco. It's scary, and the end goal appears daunting. Oh, and it can be frustrating.

As a result of this, it seems that many people set out to learn Vim, sort out how to do some basic commands like append text, go to a particular line number, and search for strings, and then stop putting effort into learning more. Basically, people reach a minimum level of competence to be successful, and then stop learning. In truth, if you are using Vim like this, you really aren't getting anything out of it. You would almost certainly be more productive using something like Sublime Text, and using Vim doesn't afford you much other than not needing to boot into an X-server to edit files.

Additionally, to do something well, you should have a firm grasp of how to use the tools of your trade. Imagine a painter that couldn't use oil paints correctly, or an auto mechanic that couldn't use a wrench properly. The same is true for programmers, and it takes practice =).

The true power of Vim comes from its modal nature, rather incredible editing features, the depth of its configurability, and the plethora of amazing plugins. There is a reason that Vim command keys are re-used in surprising places, and despite decades of having a reputation of being 'very difficult', it remains one of the most popular editors, amongst programmers, in the world.

My goal in this post is to convince you to stop being scared of Vim, to embrace its capabilities, and become an insanely productive programmer. I will discuss the best ways to learn Vim, some of plugins I use and why they are so awesome, and how to get an ├╝ber-1337 Vim configuration up and running, complete with every plugin discussed in this blog post, in just a couple of minutes.

Not Another Vim Tutorial

Vim and Its Capabilities

Vim is the most capable editor that I am aware of. Indeed, I would venture that it is even more capable than full Integrated Development Environments (IDEs), like Eclipse. Obviously, Vim isn't an IDE on it's own (I use a combination of Vim and some terminals for a full DE), but there are no features, that I've seen, available in large-scale IDEs that aren't available as part of Vim-core or in a popular plugin. Additionally, there are a number of really impressive plugins that provide functionality that I haven't seen matched by any other editor or full IDE.

Part of this post will be a run-down of every plugin I use and what they let you do.

A Note About Emacs

Vim is most often compared to Emacs, and the "Holy War" between the two even has its own Wiki Page. At this point, I think it is safe to say that there is nothing one can do that the other can't, assuming someone has bothered to write the /[Vim Plugin | Emacs Script]/ for it. There are a things Emacs has that Vim doesn't (e.g., Org-Mode, a built-in Lisp Interpreter), but there are also loads of things provided by Vim and Vim plugins that Emacs hasn't matched, yet. If anything, the "Holy War" keeps both development communities actively developing and improving, which benefits everyone.

If you are trying to decide between Vim and Emacs, choose based on how you want to edit and think about text. Vim is modal, whereas Emacs relies on modifier-keys. Look at how each is configured, which makes the most sense to you, and go from there.

The Right Way to Learn Vim

There is a right way to learn Vim, and to 'think in Vim', and a lot of wrong ways. For example, there are tons of tutorials out there that advise things like:

* Reformat the entire file: `ggvGgq`
* Surround word under cursor with brackets: `viws[`

NO. Tutorials like these should be universally rejected. The problem with these sorts of tutorials / references is that they encourage you to memorize random keystrokes to get things done; you aren't actually learning how to use Vim.

One of the most powerful things about Vim is that once you learn "the language of Vim" (e.g., which keys execute which commands, how to navigate word, sentence, paragraph, and buffer objects) you can execute tremendously powerful editor commands in less than a second or two. This sort of power and functionality is core to the editor design. My favorite description of this comes from Steve Losh, who I consider a rockstar of the Vim world. He calls it the "Language of Text Editing".

If you learn Vim right, instead of trying to remember, "What was that string of keystrokes I'm supposed to use to reformat the file?", you will think, "I want to reformat the file. Select the current buffer, execute the reformat command."

The ability to put together your own command strings is crucial to being a productive and powerful Vim user, and that is what good tutorials should teach you.

Vim's tremendous feature set means learning everything is an on-going process. Don't worry about trying to learn everything at once. Pick some cool features you want to get comfortable with, practice them, and then move on to the next cool thing.

I want to stress that there really isn't a zenith in the curve of you learning Vim. I have been using Vim, exclusively, to write code for over 10 years, and I am still learning things. This is one of the aspects that gives me confidence that I will stick with Vim - I still haven't exhausted / taken advantage of all of it's features.

Awesome Tutorials

There are loads of Vim tutorials out there - far more than necessary, really. You can buy books from professional publishing houses (e.g., O'Reilly's Vim Books), download e-books written by enthusiasts, and watch screencasts of people giving more personal tutorials.

Here are some links to some really fantastic learning resources:

For just a quick run-down of commands, presented in a way that makes sense relative to how Vim programmers need to think (i.e., execute command on object), check out this great page: Vim Introduction and Tutorial

Finally, there are a number of useful 'cheat sheets' out there for quick references, if you find them useful:

Clearly, a lot of people are very passionate about Vim.

The purpose of this post isn't to add yet another Vim tutorial to the world. The resources linked above have all done a much better job than I likely would, and they have devoted a lot of time to putting together really great references and learning experiences.

My goal in this write-up is to convince you of why learning Vim properly is worth the effort, help you get up and running with an awesome configuration and set of plugins, and give you a run-down of all the awesome stuff ahead of you. I learn something new and awesome about Vim almost every week I use it, and it is exciting and impressive every time.

Getting the Ball Rolling

For years, I actively developed what I thought to be a pretty sweet Vim configuration file, commonly referred to by its filename, vimrc. I added to it gradually, and it had some fairly unique features.

Enter Steve Losh. I was totally unfamiliar with him prior to this, but he made what would become a rather seminal blog post in the Vim community called "Coming Home to Vim" in September of 2010.

If you read his blog post, you'll note that the Plugin list in this blog post closely resembles his. Actually, if you look at my vimrc, you'll notice it basically is his. I owe, essentially, the entirety of my Vim configuration to Steve. Thanks, Steve!

Steve's work on Vim made many of the very advanced features easier to use, and he has since gone on to write a number of very useful plugins. He recently published a book about scripting in Vim, "Learn Vimscript the Hard Way".

Let's go over what you need to know before diving into the plugins.


Firstly, configuration. You'll want an awesome vimrc to compliment whatever awesome code you are hacking on.

I maintain my entire Vim configuration directory, including plugins, on Github
(Losh does the same thing, by the way, but on bitbucket, using Mercurial). What this means is that all you need to do to exactly clone my Vim setup is to get a copy of my directory and make some symlinks so that your local Vim executable will find the files.

My vim directory also includes additional colorschemes I have added to Vim, snippets for the snipmate plugin, etc., I recommend looking through it to see what is available.

I actually do this every time I want to setup my development environment on a new system. I just download my directory, symlink it, and I'm done. Here's what you need to do:

First, pull down the code to where ever you would like to keep it. Note that I use git submodules for all of the plugins, so you'll need to do this recursively to get everything.

$ git clone --recursive bhilburn-dotfiles.git

Second, we need to make some symlinks so that your Vim executable can find the files. We will need one for the vimrc configuration file, and one for the ~/.vim user directory.

$ ln -s bhilburn-dotfiles.git/vim/vimrc ~/.vimrc
$ ln -s bhilburn-dotfiles.git/vim ~/.vim

Now, go build something cool =).

I highly recommend reading at least this section of Losh's post about his vimrc, and then perusing the vimrc you just pulled down from me. You don't need to know all of the Vimscript commands to understand what they are doing, generally. If you don't read through the vimrc to see what is there, you are going to miss out on a lot of the good stuff, and Steve's post does a great job of breaking down some of the commands in detail.

Reading your fancy new vimrc is the best way to get a feel for all of the awesome shortcuts that are now available to you.

Basic and Semi-Advanced Vim Features

Before trying to make use of all of the plugins in the next section, I highly recommend that you at least understand some of the more 'advanced' editing features of Vim. These are all covered in the numerous tutorials I linked above.

If you are still moving the cursor around in Vim using the arrow keys or by clicking around with the mouse, it will be difficult to take advantage of many of the awesome features the plugins provide.

Learn your navigation keys (b, B, w, W, e, E, ge, gE), and how to work with text objects! These are all covered in the tutorials covered above, and this link (also from above) is a great reference: Learn your navigation / object keys!

If using the command cw to replace a word, or cs"' to change surrounding " to ' are things you aren't familiar with yet, you have barely scratched the surface of Vim! Please go through some of the tutorials listed in this blog post =)

Some examples of other semi-advanced features you should at least know about:

There is also this fantastic post on Super-User that covers a lot of these in one place: Understanding the 'Improved' in Vim

You don't need to be super comfortable with all of the above to make use of the plugins in the next section, but if you aren't you may find yourself trying to tackle learning too much at once and getting slightly overwhelmed.

Plugins - Make Your Vim Amazing

How to Use / Install Plugins

I load and install all of my plugins using the excellent Pathogen, by Tim Pope - another great prodigy of Vim who has made incredible contributions to the community.

Pathogen makes it possible to simply dump plugins into a ~/.vim/bundle directory, and then Pathogen will automatically load them when you open Vim.

This is really awesome, because it means you can git clone a new plugin directly into the bundle directory, and it will load the next time you open Vim. You'll note that all of the plugins, for the most part, in my bundle directory are actually just git submodules, which makes pulling down updates for each one a snap.

The Plugin List

[Update: For an updated list, check out this recent post, with instructions on how to get it all running]

This is quite a list! Many of them do things that will become immediately useful to you without you ever knowing about them. Others provide functionality that you actively invoke from Vim.

I have no intention of documenting each plugin here - the developers have already done that. I'll just tell you what it is, why you want it, and where to go for further documentation.

All plugins listed here are distributed in my vim directory, as well as a few others. I have left off of the list plugins which make minor tweaks / changes to Vim, some of which will likely eventually be merged into the primary ViM distribution, plugins that just add additional file detection and syntax files, and plugins which just add a colorscheme or something similar. For a full list, just look in ~/.vim/bundle

Again, just to clarify, if you download my vim directory, as described above, you already have all of the below plugins installed. This is just a list to show you what's in there, and where to get more info about them.


This plugin lets you search for an arbitrary word and manage what is found. Think of it like using 'grep' from within Vim, and then being able to sort the results, open the files that interest you, and interact with them all as just another Vim buffer.

My favorite way to use this is to select a word in Vim and execute the Ack! command. It means you don't need the terminal for the same functionality.

Vim Ack Plugin

If you happen paste in text that use ANSI escape sequences, Vim's default rendering of these was functionally correct, but looked distracting. Handle them like a sane person.


Easily run shell commands and dump the output into a Vim buffer.

Video of how awesome it is: Clam Screencast

The plugin: clam.vim


With just a quick keystroke, comment out lines or blocks of selected text for any language that you have a syntax file for.

Tim Pope's vim-commentary


Another plugin that lets you do things inside of Vim that you otherwise would need to do manually from inside a terminal. This plugin lets you easily search for filenames, buffers, recently used files, etc., and open them from within your existing Vim window.


Note that I use Losh's configuration of ctrlp, which requires the fuzzy file finder that Losh write, available here: ffind

More information about using ctrlp is here: Kien's ctrlp


This plugin is so awesome, it should be illegal (as it's own documentation says). It allows you to directly interface with git from Vim, and treat outputs as Vim buffers. For example, if you are editing a file, and run the diff feature, it will open a split that shows you the git diff of your changes. Freaking awesome. It wraps most common git functionality.

Example screenshot posted on coderwall:

Awesome, right? Find it here: Pope's vim-fugitive


Another awesome one from Losh. This one shows you your tree of undo / redo changes, and lets you return to any point in history and carry on from there. This is best explained by Losh's screenshot:


Find it here: gundo.vim


I love this plugin. Select one area of text and mark it. Select a second section of text, in any buffer, and mark it. linediff will then open a new buffer showing you the vimdiff between the two chunks of text you highlighted.

If you aren't already familiar with vimdiff, be sure to check it out!

An awesome screenshot from Tom Ryder:

Find linediff here: linediff.vim


One of the most popular Vim plugins ever made. It gives you an awesome filebrowser in a small split so that you can easily handle your project directory.

A very cool screenshot taken by Daniel Fischer


Thanks, scrooloose! nerdtree


This plugin gives you, hands-down, the coolest statusline ever.


Thanks, Lokaltog! Vim Powerline


Gives you all sorts of awesome features for editing Python, including Python checkers, amazing code completion, running bits of code directly out of your buffer, better support for Python Vim objects, etc.,

Nice, Kien. python-mode


Another one from Kien, this turns of "Rainbow Parenthesis". Basically, this means that each set of parenthesis / brackets / square brackets / etc., is color coded, so you can easily tell what the matching bracket is if you have a bunch of them together.

An example from Losh:


Find it here: Rainbow Parethesis


Superior Lisp Interaction Mode Vim (SLIMV). If you are a Lisp programmer, you will love this.

You can find it here: slimv


An example of Vim learning from another editor, in this case TextMate, this plugin lets you quickly insert snippets of code that you can then customize. For example, for a for loop in C/C++, I just type for, then press tab, and a loop appears. The editor then automatically cycles me through parameter that I may need to modify. Loads of useful snippets are already provided in my vim/snippets directory.

The plugin is here: snipmate


Write HTML code much easier. Check it out in action:

Find the plugin here: sparkup


Tab-completion of variables, functions, etc., is a common feature of editors, now. Vim provides this, but accessing it, by default, requires remembering a number of different commands. This plugin makes them all available just be pressing tab.

Find it here: supertab


Another big productivity-booster. With this plugin, you can quickly surround blocks of text with some form of bracket or quote, or change what it is already surrounded by to something else. Extremely useful in just about every programming language.

Another one from Pope. vim-surround


The plugin that scrooloose is most famous for. This plugin provides pretty incredible compiler-level checking of your code, from within Vim. You really have to see a screenshot to understand it:


Find it here: syntastic


Ever need to align a bunch of text on a colon or = sign? Like in a makefile, or in a long initialization list? This plugin makes that automatic.

Find it here: tabular


If you have used a modern IDE, you are probably used to having this. It gives you a complete list of your functions / objects / classes / files / etc., from an easily-accessible window, and lets you navigate to any of them just by selecting one.

Here's a screenshot:

You can find more info here: taglist


Send a command to a running tmux session.

Simple, useful. tslime


I haven't been including plugins like this one on this list, even though they are in my directory, but this one is worth looking it. It adds a bunch of very useful keystrokes.

Another one from Tim Pope. vim-unimpaired


Another great utility plugin. It maintains a ringbuffer of all of your yanks / deletes / etc., so that you can cycle through all of them. Basically, you are no longer limited to yank1 --> paste1 --> yank2 --> paste2. You can now yank1 --> yank2 --> paste1 --> paste2.

Find it here: yankring


I hope showing you the above is not only very useful, but gets you excited about diving deeper into Vim! It is truly an incredible piece of software, and the fantastic community around it continues to make it better. It makes programming, to me, feel good, and I've found that becoming more proficient in Vim actually makes me more excited to sling code.

A special thanks to the numerous Vim developers who have made some of the incredible plugins above, and from whom essentially my entire Vim configuration comes from:

Happy Hacking =)

Ben Hilburn

Ben Hilburn

bits, nibbles, bytes, and words
D.C. Metro Area