vim plugins

Posted 2016-05-08

As a vim nerd, one of my favorite things to do is find out ways to make vim more useful. vim is an incredibly powerful text editor, but without any bells and whistles it can feel lacking in the convenience provided by IDEs and text editors like Sublime Text.

Without further ado, here are some plugins that make vim even more fun than an IDE.

neocomplcache

is a great autocompletion plugin for vim. It has filepath autocompletion, which is one of my favorite features.

vim-multiple-cursors

provides multiline text editing similar to that in Sublime Text. I don’t know how I ever lived without this plugin. Changing variable names is so much easier!

gitgutter

shows change/deletion/addition markers (like those shown by git diff) down the side of a file tracked by git. It gives me a lot of peace of mind when I can see exactly what I’ve changed since the last commit, while I’m working on the code.

GitGutter can color-code the actual lines of text to show changes as well as using markers in the sign column. In my .vimrc I decided to make a mapping for enabling this. I also shortened the delay between making a change and it being marked by the plugin.

GitGutterEnable
 	" delay before showing signs
setlocal updatetime=250
 	" mapping for color-coded lines
nnoremap <Leader>l :GitGutterLineHighlightsEnable<CR>

vim-script-runner

runs code written in various scripting languages at the tap of a key, and shows the output in a split window. I have wanted something like this for a long time, as one of the main reasons I will sometimes opt to use Sublime Text instead of vim is the ease of running code during testing.

The only configuration I’m using so far is remapping the script runner key to something more like Sublime Text:

let g:script_runner_key = '<Leader>b'

vim-airline

is a pretty status line for vim, providing (among many other more exciting things which I haven’t tried yet) trailing whitespace warnings, file modification indicators, a vast array of color themes (I went through every single one to find my favorite), and addition/deletion/change counts…oh, and don’t forget the color-coded editing modes, which save many an accidental insertion. Another “how did I ever live without this” plugin.

Not much config needed for basic use:

set laststatus=2 " always show the status line
let g:airline_theme = 'luna' " my choice of theme

syntastic

automatically checks syntax every time you save a file (or only on demand, if configured to do so) and integrates with vim-airline so you get syntax errors pointed out to you in the status line.

The recommended configuration for this plugin shows a list of errors AND warnings in a split window, along with the status line marker, symbols in the sign column, and markers in the actual text itself. I opted for a more minimal config - the following only displays errors, not warnings, and doesn’t show the split window error list:

let statusline+=%{SyntasticStatuslineFlag()}
let g:syntastic_quiet_messages={'level':'warnings'}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

Update: After using syntastic for a short time I ended up disabling it because it slowed down vim so much, eventually crashing it completely.

nerdtree

provides a nicer alternative to vim’s explore function. I’ve only been using it for a few hours and I’m already in love with it!