Getting Started with Vim Plugins: A Beginner's Guide to vim-plug
Table of Contents 📑
So you’ve found an exciting Vim plugin—perhaps for journaling with Vimwiki—and you’re ready to supercharge your editor. This guide will walk you through setting up vim-plug
, a fast, minimalist, and incredibly popular plugin manager. Once you’ve completed these steps, you’ll have a solid foundation to install any plugin you want, unlocking the true power of Vim.
What is a Plugin Manager and Why vim-plug
?
A plugin manager automates the tedious process of:
- Downloading plugin files from sources like GitHub.
- Placing them in the correct directories.
- Loading them when Vim starts.
- Updating and removing them easily.
I recommend vim-plug
because it is:
- Minimalist: It’s just a single file, making installation trivial.
- Fast: It can install and update plugins in parallel.
- Easy to Use: The commands are simple and memorable.
Step 1: Install vim-plug
vim-plug
itself needs to be downloaded first. The official and easiest way is to run a single command in your terminal. This command downloads the plug.vim
file and places it in Vim’s autoload
directory, which ensures it’s loaded automatically when Vim starts.
Open your terminal and execute:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
That’s it. The plugin manager is now “installed.”
Step 2: Structure Your .vimrc
for Plugins
Next, you need to tell Vim which plugins you want to use. This is done in your ~/.vimrc
file inside a special block.
- Open your
~/.vimrc
. - Add the following structure. All your plugin declarations must go between the
call plug#begin()
andcall plug#end()
lines.
" 1. VIM-PLUG SECTION
" This block must be at the top of your .vimrc
call plug#begin('~/.vim/plugged')
" List your plugins here
" Example:
Plug 'vimwiki/vimwiki'
Plug 'dracula/vim', { 'as': 'dracula' } " A popular theme
call plug#end()
" 2. YOUR CONFIGURATIONS
" All other settings go AFTER the vim-plug block
syntax enable
colorscheme dracula
let g:vimwiki_list = [{ 'path': '~/vimwiki/' }]
" ... and so on
plug#begin()
: Initializes the plugin manager. The argument ('~/.vim/plugged'
) is the directory wherevim-plug
will download and store all your plugins.Plug 'author/repository'
: This is the command to declare a plugin.plug#end()
: Finalizes the list and loads the plugins.
Step 3: Install the Plugins with :PlugInstall
Now that your .vimrc
is configured, you can tell vim-plug
to fetch and install the plugins you’ve listed.
- Save your
~/.vimrc
file and restart Vim, or source the file with:so ~/.vimrc
. - Run the
vim-plug
installation command inside Vim::PlugInstall
- A new window will open, showing the installation progress for each plugin. Once you see “Finished!”, you can close the status window (
:q
) and start using your new plugins.
Your Plugin Management Cheat Sheet
Managing plugins is now simple. Here are the essential commands you’ll use:
:PlugInstall
: Install any new plugins you’ve added to your.vimrc
.:PlugUpdate
: Update all installed plugins to their latest versions.:PlugClean
: Remove any plugins that are in yourplugged
directory but no longer listed in your.vimrc
.:PlugStatus
: Show the status of all your plugins.
Summary: Your Foundation is Ready
Congratulations! You have successfully set up a robust system for managing Vim plugins. You now understand:
- How to install
vim-plug
. - How to structure your
.vimrc
to declare plugins. - How to install, update, and manage them with simple commands.
You are now fully equipped to customize Vim to your heart’s content and can confidently follow tutorials like our guides to setting up a Vimwiki journal or creating a dual-journaling system.
ℹ️ A NOTE ON THE <LEADER> KEY |
Many Vim tutorials (including ours) use shortcuts like You can set it to a more convenient key, like the comma, by adding this to your |