Plugins: The Short List Worth Installing

A Word on Plugin Discipline

Before adding plugins, turn this chapter into a rule: if a plugin does something Vim already does, don't install it. If you've only been using Vim a month, you don't know what Vim already does. Come back to this list in a few weeks.

A good plugin list is small. Mine hovers around ten.

Native Packages: No Plugin Manager Needed

Vim 8 and Neovim have built-in package support. You put a plugin in a directory and Vim loads it.

~/.vim/pack/{name}/start/     loaded automatically at startup
~/.vim/pack/{name}/opt/       loaded on demand with :packadd

The {name} is any name you want to group under (I use vendor). A plugin is just a git clone into one of these directories.

mkdir -p ~/.vim/pack/vendor/start
cd ~/.vim/pack/vendor/start
git clone https://github.com/tpope/vim-surround
git clone https://github.com/tpope/vim-commentary

Restart Vim. Plugins are loaded. To update, git pull in each directory.

For Neovim, the path is ~/.local/share/nvim/site/pack/{name}/start/.

Native packages work, require nothing, and are boring. If you have fewer than a dozen plugins, you don't need a plugin manager.

vim-plug

For anything beyond "a handful of plugins I never update", use a plugin manager. vim-plug is the most common:

Install

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

Neovim:

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

Use

In .vimrc:

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

Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'morhetz/gruvbox'

call plug#end()

Then, inside Vim:

:PlugInstall      install the listed plugins
:PlugUpdate       update them
:PlugClean        remove plugins you took out of .vimrc

That is the whole workflow. Add a Plug line, :PlugInstall, use.

Other managers exist (packer.nvim, lazy.nvim, dein). They're fine. vim-plug is enough for most people.

The Plugins Worth Installing

A short list that earns its keep, based on years of other people's .vimrc files being more useful than mine.

vim-sensible

Plug 'tpope/vim-sensible'

Flips on sane defaults most .vimrc files would set anyway: incsearch, hlsearch, showcmd, ttimeoutlen=50. Read the source once; steal what you like. Or include it wholesale and move on.

vim-surround

Plug 'tpope/vim-surround'

Manipulate surrounding characters. The killer feature:

cs"'       change surrounding double quotes to single
ds(        delete surrounding parentheses
ysiw"      add double quotes around the inner word (yank-surround)
ysiwb      add parens (b is brief for ( ))

Works with any bracket, quote, or HTML tag:

cst<p>     change surrounding tag to <p>
yss)       surround the entire line with ()

This is possibly the most useful Vim plugin. Install it.

vim-commentary

Plug 'tpope/vim-commentary'

Toggle comments. gcc toggles the current line, gc{motion} toggles a range, gcap toggles a paragraph. Works across filetypes automatically.

gcc        toggle comment on current line
gcap       toggle comment on a paragraph
visual + gc     toggle comment on a selection

vim-repeat

Plug 'tpope/vim-repeat'

Makes . work with plugin commands. Without this, . only repeats native Vim operations. Install it alongside vim-surround and vim-commentary so . repeats their actions too.

vim-fugitive

Plug 'tpope/vim-fugitive'

Git inside Vim:

:G              status window
:G blame        blame for the current buffer
:G commit       commit
:G log          log
:G diff         diff
:G push         push

The status window is the star. Press - to stage, = to see the diff, cc to commit, and so on. Learn a handful of mappings and you may stop reaching for the git CLI in half your interactions.

fzf and fzf.vim

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'

Fuzzy file search, buffer switching, and line search. Requires the fzf binary (install from Homebrew, apt, or let the plugin install it).

:Files          fuzzy file picker across the project
:Buffers        fuzzy buffer picker
:Rg pattern     ripgrep, with a live picker
:Lines          fuzzy search across all open buffers
:Commits        git log, interactive

Map a few in your .vimrc:

nnoremap <leader>f :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>g :Rg<CR>

Project navigation becomes near-instant.

A colorscheme you like

Plug 'morhetz/gruvbox'
" or
Plug 'sainnhe/everforest'
" or
Plug 'catppuccin/vim', { 'as': 'catppuccin' }

Default Vim colours work. A good external theme is nicer.

colorscheme gruvbox
set background=dark
  • vim-polyglot: syntax and indent for many languages in one package
  • vim-airline or lightline.vim: a prettier status line
  • NERDTree or vim-vinegar + netrw: file tree (vinegar just teaches you to like the built-in netrw, which is worth trying first)
  • undotree: visual undo history browser
  • ALE: linting without LSP

Don't install all of these. Install the one you notice missing.

Neovim and LSP

Neovim ships with a built-in LSP client. It gives you real IDE features: diagnostics, autocomplete, go-to-definition, rename, hover documentation.

The quick version:

-- init.lua
require'lspconfig'.pyright.setup{}
require'lspconfig'.tsserver.setup{}
require'lspconfig'.gopls.setup{}

That requires nvim-lspconfig plus a language server installed separately (e.g. pip install pyright, npm install -g typescript typescript-language-server).

For autocomplete, add nvim-cmp and related plugins. It's a project; expect an afternoon.

Vim (not Neovim) has LSP support via plugins like vim-lsp, coc.nvim, or ALE. coc.nvim is the most common for Vim users who want IDE features.

If LSP is a whole project for you, skip it for now. A good .vimrc, fzf, and tags (ctags) take you a long way.

Organising Plugins

A few habits:

  • Group related Plug lines with a comment so you remember why each is there
  • Comment out, don't delete, a plugin you're unsure about
  • Review the list every six months. Plugins rot. Some get replaced by built-ins
call plug#begin('~/.vim/plugged')

" Editing
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'

" Navigation
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'

" Git
Plug 'tpope/vim-fugitive'

" Appearance
Plug 'morhetz/gruvbox'
Plug 'vim-airline/vim-airline'

call plug#end()

Common Pitfalls

"Vim takes ages to start." Profile with vim --startuptime /tmp/vim-startup.log and read the log. Usually one plugin is the culprit. Disable plugins one by one until start-up is fast again.

"A plugin is broken after an update." :PlugStatus shows problems. Pin a version: Plug 'tpope/vim-surround', { 'tag': 'v1.2' }.

". doesn't repeat my surround change." Install vim-repeat. Most tpope/* plugins expect it.

"I installed a plugin and don't know what it does." Every decent plugin has :help {plugin-name}. Read it before writing your own mappings on top. You'll find features the author already built.

"My plugin manager feels like magic I don't understand." Switch to native packages for a week. It demystifies the whole thing. Come back to vim-plug if and when you want convenience.

Next Steps

Continue to 11-advanced-techniques.md for the features you won't need on day one but will appreciate on day one hundred.