Native support for plugins was added to Vim back in 2016 with the release of version 8's packages. Since then, I've moved from Pathogen in favor of this new feature. Although not a true replacement for existing plugin managers, when combined with Git it accomplishes the same goal. Being a believer in the less-is-more theory, it just seemed like the right thing to do. It has proven to be very easy to maintain and I don't miss Pathogen at all. Here I'll run through the basics of how Vim's native support works and share my method of keeping everything up to date.


  • Vim version 8+ (check your version with vim --version on the command line)

  • A Git repository setup somewhere. (GitHub, GitLab etc.)

Directory Structure

Vim looks for a specific directory structure within its own directory, ~/.vim by default. Duplicate the following in your .vim directory, you can rename the plugins directory anything you like but make sure the others match. Any plugin you place in the start directory will be automatically started by Vim, any you place in the opt directory will be available for manual loading when needed inside Vim via the :packadd <plugin-name> command.

    -- pack/
        -- plugins/ <-- can be named anything you like
            -- opt/
            -- start/

That's all there is to it, with the above you'll be able to place your plugins in the appropriate location and all will work but, let's take it a step further and get Git involved in the process.

Managing With Git

Now, to make it easier to keep all your plugins up to date, let's create a third directory named ‘all’. In this directory we'll put all of our plugins and then just link them into the appropriate directory as needed. This will make updating a bit easier and enabling/disabling a plugin is as easy as removing the link instead of deleting or moving the plugin's files.

    -- pack/
        -- plugins/ <-- can be named anything you like
            -- all/
            -- opt/
            -- start/

We can now start adding plugins the Git way. This isn't meant to be a Git tutorial, so I won't go through explaining everything here but, the below will initialize a git repo for your ~/.vim directory and install a plugin as a Git submodule. I'll be using vim-fugitive in this example.

cd ~/.vim
git init
git remote add origin <your-remote-repo>
git commit -am "Initial commit."
git push -u origin master

Now install the new plugin, commit the change, and push to your remote repo. Repeat for other plugins as needed.

git submodule add pack/plugins/all/vim-fugitive
git commit -am "Added the vim-fugitive plugin as a submodule."
git push origin master

The last thing needed is to create a symbolic link to the proper directory for either auto or manual plugin loading.

cd ~/.vim

# for auto loading:
ln -s pack/plugins/all/vim-fugitive pack/plugins/start/vim-fugitive

# or for manual loading:
ln -s pack/plugins/all/vim-fugitive pack/plugins/opt/vim-fugitive

Inside Vim, don't forget to generate helptags for your newly installed plugins.

:helptags ALL

Updating Plugins

There are several ways to keep your plugins updated, I'll cover a few here.

Individually, checking changes before updating.

cd ~/.vim/pack/plugins/all/vim-fugitive
git fetch origin master
git diff
git merge

Individually, without checking.

cd ~/.vim/pack/plugins/all/vim-fugitive
git submodule update --remote --merge

All at once without checking changes.

cd ~/.vim
git submodule foreach git pull origin master

Of course, after updating you'll need to commit the changes and push to your remote repo.

git commit -am "Updated plugin(s)."
git push origin master

Removing a Plugin

Removing a plugin entirely only takes a few commands.

cd ~/.vim
git submodule deinit pack/plugins/all/vim-fugitive
git rm -r pack/plugins/all/vim-fugitive
rm -r .git/modules/pack/plugins/all/vim-fugitive

I think that covers all the basics, in a future post I'll dive deeper into Git and how to use it to manage your dotfiles along with a few Python scripts I've written to automate a lot of the work. Until then, hope this has been helpful.

Feel free to send me an email with any questions, comments, or requests and if you're feeling generous, help keep me caffeinated.