I’ve gone through a few different systems since starting to use Vim, I’ve finally settled on one that’ll be tough to beat: vim-plug. A good plugin manager is essential to any good Vim configuration, in my opinion. It allows me to easily add, remove and update plugins as well as keep them in sync across machines. The parallel processing and optional deferred loading are excellent features.
My configuration is modularised by having bootstrap.vim load all files in my modules directory, one of these is plugins.vim which configures vim-plug and then loads the individual configuration files for each plugin from modules/plugins. This allows my actual plugin list to remain clean and concise. I recommend following a similar pattern to keep your configuration clean.
The point of this section being: Make sure you have a good plugin manager and a nice place to list your plugins as well as their configuration. It’ll help keep things clean. Feel free to copy my system exactly, in fact, I encourage it. Fork my dotfiles if you so wish.
[.pl-s]#https://github.com/Lokaltog/vim-easymotion[Lokaltog/vim-easymotion] – The way to navigate a file quickly, regardless of language.
PeterRincker/vim-argumentative – Allows you to change the order of arguments with ease.
Raimondi/delimitMate – Automatically match pairs intelligently.
[.pl-s]#http://github.com/Valloric/YouCompleteMe[Valloric/YouCompleteMe] – The best completion engine I’ve found.
Olical/vim-enmasse – My own, allows you to edit your quickfix list and write the changes to their files. Like find and replace, but better.
ctrlpvim/ctrlp.vim – The way to jump around your code base by rough file names.
helino/vim-json – We work with a lot of it, show it some love.
junegunn/vim-easy-align – Makes those funny alignment issues trivial.
mhinz/vim-signify – Git info in the gutter.
Project specific configuration
I use embear/vim-localvimrc to provide project specific functionality such as executing tests or running the build. Because this is something that isn’t universal, having a .lvimrc to hand is extremely useful. I have the following binding defined at the moment so I can just hit “<localleader>tt” (which is “|tt” right now for me) to test this file, it doesn’t matter if I’m in the source or test file, it just works.
command! Test Dispatch grunt test-dev --filter %:t:r nnoremap <localleader>tt :Test<CR>
This is relying on vim-dispatch to make the whole thing asynchronous. It actually executes in a tmux split and pulls the results into my Vim quickfix list when done.
I also have my path set to some greedy globs and suffixesadd set to contain .js. This allows me to press gf (open file under cursor) on the following require statement, and it will actually take me to the source (if it exists)!
// Where httpService.js exists somewhere in this project. // I press gf within the quotes and it will take me there. var httpService = require('httpService');
And here’s the configuration I’m currently using for that particular bit of magic.
set path+=**/src/main/**,** set suffixesadd+=.js
I use UltiSnips to manage my snippets, which is a fantastic tool. The key to snippets, however, is to not have too many. That is why I only have three at the time of writing. It’s pretty obvious what they’re for, the most used being fn. Having a few for your most common patterns is a good idea, but delete them if you find you’re not using them, keep your snippets clean.
Expanding and concealing
This is where my vim-syntax-expand plugin comes in. Here’s a quick demo to give you an idea of what I mean if my previous paragraph was not clear.
The < to “return” mapping uses a special rule that will only work if you’re at the beginning of a line, so you can still type “⇐”. Here’s my full configuration, which is also featured in the repository README.md.
I’ve been using it for around and week so far and it feels great. I guess I’m just yearning for a more concise functional language. I type fn, hit “<C-j>” and I get a lambda symbol and a block to write in. Then I can return true by typing “< true”.
This is the sort of thing Vim is amazing at, removing the cruft between you and your text, so you can edit without thinking and concentrate on the problem at hand. Yes it takes practice to use efficiently, but so does every good tool.
[#eow-title .watch-title]#This is Shia LaBeouf responding to your “should I give Vim a go?” thoughts.