For me, vim is a toy that keeps me engaged with coding every day. It’s simultaneously fun and useful, like driving a stickshift. It seems like there’s always some new way to use it, some trick to add to my arsenal that makes me incrementally faster and more efficient. I think a lot of vim users feel this way.
Interestingly, though, I know a lot of engineers who have used vi or vim for a long time yet have never really explored the
vimrc or vim plugins very much. Similarly, I know a lot of engineers who won’t consider using it because they feel that it lacks the power and integrations of their IDEs. Well, I say that through customization and plugins vim can surprise both of these types of engineers, retaining its speed and elegance while nearly becoming an IDE itself.
This article is aimed at these two groups: people who use vim but haven’t explored the wide world of vim plugins, and people who are curious about learning vim but don’t think it can chalk up to more modern tools.
I’d like to share the 5 plugins that have increased my productivity and happiness the most, the top 5 I recommend starting with if your
vimrc looks like this:
Or if you didn’t know vim could look like this:
There are a ton of ways to install vim plugins. If you already have a favorite, and it’s not vundle, I’ll mumble something opinionated under my breath, but whatever makes you happy! Visit that link to learn how to use it. After some initial setup, installing a new plugin is as simple as adding a line to your
vimrc and running the
My favorite plugins
I’m obsessed with fuzzy finders. As a general feature, I think they have increased my productivity and happiness more than any other type of tool an editor may have. I never considered them until using Sublime Text, which has one of the best fuzzy finders out there, and this provoked my search for a vim plugin of similar caliber.
That plugin is ctrl-p, a “Full path fuzzy file, buffer, mru, tag, … finder for Vim”. At its simplest, you press
control-p and start typing fragments of the path to a file, and ctrl-p will show you a list of files that match what you’re typing in real-time.
It’s useful for both finding files you sort of know about and for ones you definitely know about. For instance, if you know there’s a file ending in
_reader.html in a
templates folder somewhere, you could press
ctrl-p and type
tmp_read and, more likely than not, the file list will be resting on
base_reader.html. You can then press
enter to open it (or
ctrl-x for a split or
ctrl-v for a v-split, and so on).
Personally, I find that I move slower as a developer if I don’t have my bearings on the structure of the codebase. Having a visual tree is important to me; it’s like driving with a map open on the dashboard. NERDTree satisfies this need of mine, replacing vim’s built-in netrw file navigator with a nicer-looking, less buggy, more fully featured alternative.
The NERDTree GitHub page describes a few tricks for this plugin, like bringing up the tree navigator when vim starts up, or only when vim starts up with no specified files. Check out vim-nerdtree-tabs to make it feel even more like an IDE tree panel.
Beyond file navigation, NERDTree can do some pretty advanced stuff, but it’s incredibly useful at its most basic, too.
vim-airline is a slick, lightweight status bar that sits quietly at the bottom of your buffer, providing you with a wealth of information. This includes your current vim mode, git branch, file path, file type, encoding, and more. vim-airline is kind of a spiritual successor to vim-powerline, written in pure vimscript and thus eliminating the need for python support.
The status bar comes out of the box with a setup similar to the one pictured below, and it is easily customizable with regular statusline syntax. Furthermore, vim-airline has no-op integrations with an impressive number of plugins, like ctrl-p, NERDTree, Syntastic, and virtualenv.
EasyMotion makes jumping to specific characters in the visible portion of your file effortless. Simply press
leader-leader and a movement, and all currently visible possible matches are highlighted with one key to press to jump to that location. For example,
leader-leader-f-b will highlight all
bs ahead of the cursor with jump-to keys.
leader-leader-b will highlight the first character of every word before the cursor with jump-to keys.
Before and after a
Probably nothing saves me more compiling/debugging time than Syntastic. The premise is simple, so there’s not much to say: it’s a syntax checker that can show you warnings and errors either on demand or on save. It uses external syntax checkers, so it works for basically all popular programming languages, from Fortran to CoffeeScript.
So, for Python support, you’d install Syntastic and
pip install flake8, and you’d be good to go.
The image below shows how Syntastic reports errors via vim-airline. The file contains an unused import, PEP8 unhappiness, an unused local variable, trailing whitespace, and an undefined variable.
Other noteworthy plugins
- fugitive.vim – “a Git wrapper so awesome, it should be illegal”
- surround.vim – “quoting/parenthesizing made simple”
- NERD Commenter – Easy commenting/uncommenting commands
- NERDTree tabs – “NERDTree and tabs together in Vim, painlessly”
- ack.vim – Integration with the ack program (better grep)
- Tagbar – “Vim plugin that displays tags in a window, ordered by scope”
- neocomplcache – “Ultimate auto-completion system”
- jellybeans.vim – “A colorful, dark color scheme”
- vim-pencil – If you’ve ever wanted to turn vim into a word processor, start here…