- Unsupervised Learning
- Posts
- Vim Config Update: 2019 Edition
Vim Config Update: 2019 Edition
I like to update my Vim configuration every 2-5 years just to make sure I am working with the latest and greatest version of Vim and that I’m doing things efficiently.
Check out my full Vim Tutorial
The last few upgrades I’ve been focused on one thing: simplicity. In my previous cycle that meant moving from Vim 7.x to Vim 8, which included a completely different way to manage plugins.
This time the impetus is a book—specifically Modern Vim, by the excellent Drew Neil—and I’m using it to not just update with some new tricks, but also to further simplify my Plugin management.
So what you’ll find below are all the changes I made to my config for 2019.
1. I moved to Neovim
The Modern Vim book that I just read—so basically Drew Neil—was heavily pushing Neovim so I decided to take a couple hours to explore it.
The TL;DR is that it’s a much cleaner (like 30% less code), more performant version of Vim with a better development community. Check, check, and check.
They had me at codebase reduction.
So I migrated. But I didn’t use the training wheels approach to do so, which is importing your previous .vimrc. Oh no—no, I started from scratch, and it felt really good.
2. .vimrc pruning
The first thing I do when I start a Vim update/cleaning session is go into my .vimrc file and pull out stuff I don’t understand or remember. Usually this is from some random thing I heard of somewhere and wanted to try, or from some previous hack regarding plugins.
It feels amazing to start with a completely new config file.
Neovim uses init.vim as its $VIMRC file instead of .vimrc.
Ideally I like to remove any config setting in there that I don’t understand, but over time these grow so as to make that difficult. This year, though, I really did it because when I moved to Neovim I started from an empty conf file and only added very few things to it.
3. Updated Plugin management with minpac
Ok, so this is the craziest thing. Plugin management in Neovim (using Minpac) is Perfection. It’s Valhalla.
Vim 7.x preferred Peruvian Chickens from the mountain regions.
In previous versions of Vim you had to sacrifice all sorts of animals to be able to manage plugins. You could do things manually, you could use Pathogen, you could do custom stuff—etc. But it was all kind of gross.
With Minpac, you just put the plugin’s git repository in your conf file, and it manages installation and updates for you automatically.
Even with the latest upgrades in Version 8, you still had management problems with plugins that you had in plugins/bundle/something/something/ because if they were git repositories (why wouldn’t they be) then you often got errors when you tried to update them.
The only plugin you have to actually install is Minpac.
Well, now there’s a new system altogether, called Minpac. It’s spectacular. For plugin management you just point to your plugins’ GitHub repos in your $VIMRC and it does everything for you—including installation and upgrades. All you do is run a simple command and they either install or update based on whether they’re already there.
Vim plugin management using Neovim/Minpac
Minpac is what package management should have been all along.
Unsupervised Learning — Security, Tech, and AI in 10 minutes…
Get a weekly breakdown of what's happening in security and tech—and why it matters.
In fact, you don’t even have to start with plugins installed (other than Minpac) since Minpac installs them all into its own folder structure and handles everything.
4. A few new tricks
Ok, so in addition to the big things (Neovim, new plugin management, and a new config), here are a few nuggets of goodness for my $VIMRC I’ve picked up in the last few days of studying.
# Copying and pasting from the system clipboard
You can also combine both clipboards into one with a setting, but it’s better to have the option and use these mappings.
It’s always been annoying to have two separate clipboards—one in Vim and one in macOS (or whatever OS you’re on). Well now you can deal with them both independently or copy and paste between them.
vnoremap y "+y
# Changed my leader key to "'" (single quote)
I’m still chasing the perfect leader key.
I’m a huge fan of using leader shortcuts, but for some reason the SPACEBAR wasn’t working for me. So I changed it to ' a single quote, which is one key to the right of my right hand’s pinky finger. Super efficient.
# I remapped the ":" shortcut (which normally requires Shift-;), to ";"
I also have CAPSLOCK mapped to ESC within macOS.
This just makes it easier to enter commands from within Vim. When sitting normally on the keys, my right pinky is already sitting on the ;, and now it’s just one pinky stroke instead of a SHIFT-; chord.
# Added a few key leader shortcuts
I’m a bit torn on these because certain replacements feel like blasphemy.
And finally I added a few new leader chords for doing regular Vimmy things, like saving, saving and exiting, and exiting without changing anything.
Save file (leader-w)
Save and exit (leader-e)
Exit without saving (leader-q)
Summary
So this was a big update! Here’s what we accomplished.
I’m now using Neovim instead of Legacy Vim.
I’m sporting a completely new $VIMRC that I fully understand every single line of.
I’m now using a completely new way of managing plugins that handles installation and updating of plugins all through the $VIMRC.
And I added a few new tricks as well.
Solid upgrade for 2019.
And for anyone who wants to see my config, here it is.
Notes
There is some wrangling that needs to be done to get Neovim installed and configured, but it’s outside the scope of this article. It’s not too terribly difficult really; it’s mostly just realizing that Neovim works off of a init.vim file instead of .vimrc, and that it uses a different directory structure. Other than that most stuff is pretty close to identical.
I’ll be adding a lot more back into my config, but this is exactly how I wanted to start—lean and mean.