At the official end of my Python IDE series, I said I’d do a writeup on my Vim setup, to show what I like, and what I expect my text editor to do in helping me to both navigate and write code without getting in the way. It’s taken a long time to get around to, but here it is. ** * **
Ctrl-P is very much the Vim-counterpart of Ctrl-P in Sublime Text 2. You use it for finding files in a project. It supports fuzzy matching, regexes, and lots of other cool things. I find navigating my filesystem really boring and tedious, and Ctrl-P helps with that a lot. I’ve also got Ctrl-J mapped to buffer-mode, so I can search for buffers by name quickly.
Previously I used Buffergator/Minibuf Explorer for buffer management, but they were cumbersome and conflicted with the way I like to do things. On top of that, Ctrl-P gave me everything I needed, and I figured one less plugin is a good thing.
TL;DR: Navigating files within a repository, and open buffers.
Syntastic is the be-all, end-all of syntax checker plugins in Vim. It supports tonnes of different languages, and different tools for each language, too. Due to my Python background, prior to Syntastic I used pyflakes and nothing else. I really don’t recommend going down that path. Syntastic is the future!
TL;DR: Provides error checking tools for a lot of languages with minimal fuss.
iwilldiffer uses the sign column on the left of the line numbers to highlight changes lines since the previous commit. I like it because it’s written in Python, so I can modify it. There are a few alternatives out there, but the documentation isn’t great for all of them, or they only support a single VCS. iwilldiffer supports mercurial, git and bazaar.
TL;DR: Showing pending changes to a file without having to run the diff tool manually.
If you use the
T commands, you know how useful it is for
jumping to the next, second, or even fifth occurence of a character. But what
about the 79th? What if you’re staring at the word you want to jump to, and
searching to get there is is too much effort? vim-easymotions is really good
for that. The default config of
<leader><leader><command> will label all
matches, so you only have to type in that label to reach it. Really nice for
jumping around quickly.
TL;DR: Nicer tools for
t commands when jumping to extreme
A decent status line. Not much more to say on it - it’s coloured for various states you’re in, shows encoding, syntax and filetype. I went with the old one that is no longer maintained, because unicode symbols actually work, and it doesn’t add 500ms of startup time to Vim.
TL;DR: Tersely shows useful metadata about the state of the current file and Vim.
If you’ve ever been in any of the following scenarios;
- You want delete all text inside a matching of parentheses, i.e.
- You want to replace all content inside some square brackets, i.e.
- You want to remove the surrounding parentheses, i.e.
Then this is the plugin you’re looking for. The default bindings are very
idiomatic, with the above commands provided by
are other bindings as well, like “surround this word”, but I find them less
All cards on the table, it’s a little buggy sometimes, especially with deletions and adding surroundings where previously there were none. But it’s better than the alternatives.
TL;DR: Management of parentheses and quotes.
If you’ve ever used Sublime Text 2, you know about multiple cursors. Basically you select multiple points, and start typing. Whatever you type will appear in each of the selected points. This is really useful for doing things like grouping a bunch of lines with quotation marks. Sure, you could just use search and replace or macros, but this is really nice because it’s visual. It’s quite buggy around the undo behaviour, though. But I can live with that.
TL;DR: Visualised macros.
If you’ve ever use TextMate, you’ll know what I’m about to talk about. Tab
completion for snippets of code, which is what Ultisnips is for. For the
longest time I used SnipMate, and I
really enjoyed it. Upon the recommendation that I try Ultisnips, and the
revelation that SnipMate is no longer maintained, Ultisnips has a very large
collections of builtin snippets, particularly so for python. They’re intuitive,
as well. For example an in Python, you can type
context, then press tab, and
you’ll get the method signations for implementing a context manager.
TL;DR: Snippets with lots of sane builtins.
Finally, you’re nuts if you don’t use something like Pathogen. It’s a Vim plugin for managing other plugins - you basically keep all plugins separate, so you can add, remove or update a plugin really easily.
** *: ** I found it very hard to finish this article. I frequently see a lot of blog posts about “using Vim as an IDE” and this really put me off, because that’s not really the point of what I’ve written above. I firmly believe that Vim is not and IDE, and shouldn’t be treated like one.
TL;DR: You better be using Pathogen.