How I Learned To Stop Worrying and Love Vim Plugins
I switched to Vim 6 years ago because I wanted to keep my dev setup as lean as possible. I was tired of working in heavy IDEs and wanted a light and fast environment without all the bells and whistles.
Originally, I avoided any plugins that fundamentally changed the editor. If it wasn’t a < ~5 line function I could code myself or crib from Vim’s help command, it wasn’t going in my vimrc.
Here are some minor improvements that helped me early on:
Ctrl-P is a Vim plugin that allows for fuzzy file matching within Vim, and limits its search to the root of the git repo that you are currently working in.
Press Ctrl-P when in normal mode, start typing the filename and available matches will start appearing as you type. Typing ‘Message.pm’ would have found all of the files in the above example. Highlighted matches can open in a new tab, split or vertical split.
The ack plugin is really valuable when searching through a large codebase. This lets you search for text in files from within Vim (using ack as a backend) and have the resulting matches appear in a panel below your code.
ag is a much faster version of ack, and makes this plugin infinitely more useful. Use ag with ack.vim by adding the following to your vimrc:
let g:ackprg=“ag –nocolor –nogroup –column”
One thing I missed with ack.vim was the ability to automatically sandbox your searches to your current repository, which is one of the things I love from Ctrl-P.I hacked together the following to get this behavior with ack.vim:
At BugReplay we opted to use Go for programming our backend.
Unlike some of the weakly typed scripting languages I’d used in the past, Go offered a rich set of tooling. Vim-go takes full advantage of this and makes Vim feel a lot more like an IDE, while still avoiding the bulk that a full IDE adds.
Vim-go autocompletes member methods and field names based on type. It even displays the full function signature in the autocomplete list.
This is far more useful than the rudimentary autocomplete that vim offers out of the box, which essentially just autocompletes based on words used previously in any open buffers.
Vim-go can take you to the function definition of the class/function your cursor is currently on, either in a split or new tab. This makes jumping through related files a breeze. It can also open the function’s documentation.
In order to get the autocomplete support based on type that was mentioned above, I had to move on from vim help’s 4 line tab autocomplete function to something a bit more robust. I opted for SuperTab since it didn’t require crazy dependencies to use and still felt somewhat barebones.
Occasionally, when a file takes a bit longer to open or save or Syntastic spews out a less than helpful warning, I’ll miss my original spartan setup. However, the improvements to productivity far make up for the added bloat.
6. Storing your vimrc and other config files on GitHub
My original plan was to keep Vim vanilla so that I could work on any random terminal, but storing your configuration in the cloud makes setting up a new box with your preferred configuration and plugins fairly painless.
When working on a large codebase, a lot of cognitive complexity goes into remembering file paths, or function/class definitions, or even correct language syntax.
The above tools allow me to keep less minutiae in my head at any given moment, so that I can focus on the actual problem I’m trying to solve.