This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Introduction to Vim Plugins

    Mike HartingtonMike Hartington

    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

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss