Introduction to Vim Plugins

Mike Hartington
InstructorMike Hartington

Share this video with your friends

Send Tweet
Published 5 years ago
Updated a year ago

Vim has the ability to extend its functionality through plugins that can be installed either manually or through plugin managers. We'll setup the vim-plug manager to install plugins for our .vimrc

[00:01] Vim's scripting ability allows you to use external files to enhance the Vim's functionality. To add plugins, you can either manually add them to your file system, or you can use a plugin manager to automate it.

[00:13] In our case, we'll use the Vim-plug plugin manager. Vim-plug gives us a simple way to declare what plugins we want to load, to allow in session through Git, and then reload the editor with the plugins added.

[00:28] Vim-plug does have a few requirements, so be sure to read over the documentation for your platform. To get started, we'll first need to copy the Vim-plug script into our .Vim directory. With that installed, let's open r.mrc and add a few lines to the file.

[00:48] We'll add call plug begin, and then say a directory where we want our plugins to be installed. Then we'll add plug and tell Vim-plug that we're done trying to load any plugins.

[01:05] So, [inaudible] will add a simple plugin, Vim sensible, which just sends a bunch of normal defaults for us. We'll use the command plug and give it the GitHub user name, and then the repo we want to load. In this case, we're loading a repo from tpope and his plugin, Vim sensible.

[01:23] Now we can save and quit Vim, start the editor back up again, and execute plug install.

[01:29] We'll get a small window on the left saying that we're installing the plugin. As soon as the plugin installation is done, Vim will update and we'll have the plugin running. We'll enter command mode, and use the command exit to close the installation window.

[01:46] We can take this a step further with a few additional lines of Vim script. This autocommand will run whenever Vim starts. If there is a missing plugin, it'll run the command, plug install, and then install whatever is missing.

[01:59] We'll add a new plugin to test it out. As you can see, the plugin installed without us having to enter anything, and then the window was closed as soon as it was done.