Andy Crouch - Code, Technology & Obfuscation ...

Vim-Plug Plugin Manager

Photo: Unsplash - Steve Johnson

One of the projects I have been trying to do all year to overhaul my .dotfiles. I have a raft of customisations and settings that I have amassed over the years. Non more so than for Vim.

My .vimrc file is full of quick fixes and random solutions and settings. A lot I have forgotten about or are for plugins I no longer use or need. So as I am coding a lot more at the moment and living in the terminal I figured it was a great time to sort it out.

The first thing I have changed with my shiny new .vimrc is the plugin manager. I previously used Vundle and hook up plugins as git sub modules. A few years ago this was a great solution. But, managing git sub modules is more involved than it should be. After reading what the best option was right now for managing plugins I have opted for Vim-plug. This is a super simple plugin manager that removes the need for sub modules.

To install vim-plug you just need to download it and add it to your autoload directory. You can do this on Linux with the following command:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

(Other OS’s are detailed on the projects Github page.)

You then need to add a section to your .vimrc file to define the plugins you want to manage. You define the plugins by adding a ling that starts with the word Plug followed by their Github repositories. An example will explain it better:

call plug#begin('~/.vim/plugged') 

Plug 'https://github.com/junegunn/vim-github-dashboard.git'
Plug 'tpope/vim-eunuch'
Plug 'airblade/vim-gitgutter'

call plug#end()

As you can see you can use either the full url or the shorthand url for the plugin repo. Vim-plug also allows you to defer the loading of plugins and has many different features. The project has a good tutorial and lots of examples.

Once you have added a plugin to your configuration you can install the plugin using:

:PlugInstall

And if you decide to remove the plugin after trying it then delete the entry for the plugin in your .vimrc and run:

:PlugClean

To update the plugins you have configured then just run:

:PlugUpdate

That is all there is to it. It is super simple and easy. It is also really fast as it uses parallel downloads where possible.

If you have any good plugins to recommend for Vim please contact me via twitter or email.