A month ago, I wrote a post about how I finally learned Vim. I gave a couple of simple steps that were the central focus of how I was able to switch from Sublime Text to Vim.
While these steps were the primary reason I was able to learn Vim, Vim plugins were a close second. While I had wanted to switch to Vim for a long time, I knew there would be parts of Sublime that I would miss. Little did I know the extensive power of vim plugins.
With a bit of browsing, Google-ing, and reading other developers’ dotfiles, I found a couple of plugins that would replace (at least, temporarily) certain functionality that was available in Sublime but was missing from Vim’s core. These plugins helped me slowly make the transition over to using Vim exclusively.
Here are the 5 plugins that helped me the most.
Similar to Sublime’s Package Control, the Vundle plugin is just a plugin manager (a dream within a dream?) Like many package managers today, it is inspired by Ruby’s Bundler, which is part of the reason I gravitated to it, because I’m already familiar with the Bundler model. After installing it, adding a new plugin to Vim becomes as simple as adding one line to your .vimrc file and running “:PluginInstall”
There are many plugin managers for Vim out there as well. Check out Pathogen if you would like an alternative.
One of my favorite parts of Sublime was the fuzzy file search capability that came out of the box. In Sublime, the command to open the search is “command+p” or “command+t”. I knew missing this finder would probably destroy me when switching to Vim. Luckily, there’s a Vim plugin which duplicates this functionality. The aptly named “ctrlp”.
Like all of Vim, the ctrlp plugin is highly customizable as well, which can allow you to change the plugin to your liking. For example, I changed the primary “ctrl+p” command to always flush the cache before opening the search so that it will index any new files that I’ve added. Also, you can configure it to ignore certain file types and directories (I’m looking at you ./tmp).
Ctrlp is great when you know the file(s) that you are looking for. But what if you don’t know the name of a file that you are looking for? In Sublime, you have the slide-out folder directory which will allow you to browse and navigate a project’s structure quickly.
NerdTree is a Vim plugin which will give you the same ability. Just a quick toggle (I’ve mapped it to Space + “ne”) and you can quickly open a “NerdTree” and navigate a project structure. Of course, you can do a lot more. This plugin is immensely useful when I can’t use ctrlp.
I need to quickly iterate and try new ideas when I am developing. One of my tricks to do that is to comment out a line or block of code.
In Sublime, this is fairly straightforward. However, utilizing the excellent ‘tcomment’ plugin, commenting is even quicker. This plugin maps ‘gc’ to allow you to comment out large amounts of texts quickly. For example, if I want to comment out the next five lines of code, it’s simply ‘gc4j’. Like Sublime, it will also try to automatically recognize the language of the file and apply the proper commenting syntax.
There were many times during my Sublime days when I would need to lookup and piece of code in a project. In Sublime, I would open up the project-wide ‘find-all/search-and-replace’ menu and type in what I was looking for. Sublime was usually quick to respond with where it could be found in the project.
Unfortunately, Vim does not come with current directory/project-wide search functionality out of the box, but luckily, there’s a great alternative.
The silver searcher is a *nix command line utility for replacing the search abilities of an ack or grep. And it is ridiculously fast.
Ok, I know what you are thinking…wait this is a command utility, not a Vim plugin. Correct. But, luckily some vim faithfuls have created a couple of Vim plugins which will allow you to use the silver searcher from a command in Vim. So, you can search can search an entire project without leaving Vim.
I use ag.vim. The experience is not as smooth as the command line and sometimes I have to jump out of Vim to use the full power of the silver searcher, but nonetheless, it gives me at least a close replacement to Sublime’s find-all.
I have a few more plugins that I utilize in Vim. Some I use more than others. However, none were quite as important to my transition to Vim as the ones above.
The one exception is vim-rails, which is a MUST have Vim plugin if you are a Rails developer. However, I decided not to list it, because the rest of the plugins are language-agnostic and all developers seeking to make the transition can use them.
Here’s a few others that I use:
Vim Plugins…Good or Bad?
I’ve heard the argument that some feel that Vim plugins are too much of a crutch or that customizing Vim beyond recognition hampers your ability to pair with other programmers. These are all valid points. But the goal I had set for myself was to just switch to using Vim full-time for my development, so I wasn’t concerned with pairing or that I was using plugins as a crutch. I knew I had to learn to crawl before I could run.