Plugins are 80% of what makes Vim awesome. You take this great foundation, and then you pile on 25 years worth of developers going “ooh, I bet I can make it do this nifty thing.” The result is amazing, and as far as I can tell, all those ancient plugins still work.
Everything isn’t perfect in the land of plugins. For a while it was download, and expand a zip file, or load a vimball (don’t ask). Recently there has been a proliferation of plugin managers (thank [insert deity here]), and now in Vim 8, Vim even has its own plugin manager built in. Yay.
So, you’ve got choices. This is my site, so I’m going to give you my opinionated advice. Use vim-plug. I’d love to recommend the built-in one, but as far as I can tell vim-plug still kicks its butt.
Advantages of vim-plug:
- Parallelized installation of plugins
- You can limit a plugin to specific file types, so that you don’t waste resources loading and running a plugin for Ruby when you’re editing a Python file.
- Works with older versions of Vim.
- Supports different sets of plugins for different .vimrc files.
Once you’ve pasted in the initial configuration adding a plugin is usually as simple as saying
then reloading your changes and running
bling/vim-airline comes from the GitHub url of the vim-airline plugin:
Plugins Not On GitHub
The migration of vim plugins to GitHub has been impressive, and largely fueled by the fact that the best plugin managers all make it very easy to install from GitHub. Vim has been around for 25 years though, and a there are a lot of really useful things that haven’t made it to GitHub. There are also a bunch of developers who don’t like using GitHub. If the plugin you want isn’t on GitHub your plugin manager will still have a relatively easy way to install and manage it.
Restart after install
In my experience your best plan, regardless of which plugin manager you choose, is to:
- add the plugin to your .vimrc
- source it ( See the section on reloading your .vimrc )
- tell your plugin manager to download and install it.
- then restart vim.
That being said, Vim supports plugins written in its native Vimscript, Python, Ruby, Perl, Scheme, and Tcl. Steven Bach1 has this to say about writing plugins in languages other than Vimscript:
It isn’t widely known that Vim has interfaces into several popular scripting languages: Python, Ruby, Perl, Scheme, and Tcl. These are more powerful than Vim Script but have certain practicality drawbacks in context.
Debugging is difficult. Foreign code is interpreted by what is essentially one giant eval. If you misplace a close parenthesis or an end keyword, you will have to track it down yourself.
Integration with Vim is slight.[…] The bindings just tunnel most editor interactions through Vim::evaluate or Vim::command (or equivalent) as unstructured string arguments.
Many Vim installations don’t include external language support by default. It’s an easy fix for a user running a deb or rpm-based Linux distribution, but will require a recompile on Windows, something a Windows user is not wont to do. OS X is hit-or-miss.
Steven’s article is filled with technical tips, and I highly recommend check out Steve Losh’s post with great advice for plugin creators. He’s also the author of Learn Vimscript The Hard Way. It’s free to read online, but if you find it useful please buy a copy of the eBook or print versions.