An annotated .vimrc

Some of the basic options that I require in vim 8.0:

Miscellaneous essentials

set encoding=utf8
set fileformats=unix,mac,dos
set nonumber
set clipboard=unnamedplus
set nobackup
set noswapfile
let loaded_matchparen = 1


set foldcolumn=0
set foldmethod=syntax
set foldlevelstart=99
set fillchars+=fold:.

The folding directives per language are grossly inconsistent. I found most of the settings by running grep -Rn _fold /usr/share/vim/vim80/syntax/:

let javaScript_fold=1
let markdown_folding=1
let php_folding=1
let sh_fold_enabled=1
let tex_fold_enabled=1
let xml_syntax_folding=1

Keyboard behaviours

set backspace=indent,eol,start
set expandtab tabstop=4
nnoremap <silent> <Space> :silent noh<Bar>echo<CR>
nnoremap <F9> za

Status line

set noshowmode
set statusline=%<\ %f\ %r\ %=\ %l\ \|\ %Y
set laststatus=2


Nothing really beats the terminal ron colorscheme. Vim 8.0 requires me to specify the color mode (notermguicolors) in order to prevent it trying to render gui color equivalents (which aren’t nearly as good as the terminal ones).

syntax on
syntax reset
set t_Co=256
set notermguicolors
set background=dark
colo ron

Things I also consider as belonging in the realm of colors:

set nocursorline
set colorcolumn=0

Split windows

I prefer the vertical box drawing character for vertical splits. The default is a pipe, but in most fonts that leaves a little bit of space between the stacked pipes, which is distracting. Note that | (pipe) is not equal to (U+2502).

set fillchars+=vert:\│

Filetype specifics

Some sane defaults for git commit messages, emails, Vagrantfiles, etc.

autocmd FileType gitcommit set textwidth=72
autocmd FileType mail setlocal fo=w textwidth=72
autocmd BufNewFile,BufRead *Vagrantfile setlocal ft=ruby
autocmd BufNewFile,BufRead *nginx setlocal ft=nginx
autocmd BufNewFile,BufRead *README setlocal ft=rst
autocmd BufNewFile,BufRead *.apib setlocal ft=markdown
autocmd BufNewFile,BufRead *.envrc setlocal ft=sh
autocmd BufNewFile,BufRead *.ldg,*.ledger setlocal ft=ledger cc=48
autocmd BufNewFile,BufRead *.sql setlocal ft=mysql
autocmd BufNewFile,BufRead *.toml setlocal ft=dosini
autocmd BufNewFile,BufRead *wmiirc_local setlocal ft=sh

let g:tex_flavor='latex'


When composing mails in mutt, I like the cursor to jump immediately to the first empty line (thus skipping the mail headers), and create two new lines for some initial padding:

autocmd BufRead /tmp/mutt* execute "normal /^$/\n"
autocmd BufRead /tmp/mutt* execute "normal 2O"


This is highly personal of course, but this is what’s in my toolbelt:

call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'junegunn/goyo.vim'
Plug 'tpope/vim-vinegar'
Plug 'digitaltoad/vim-pug'
Plug 'vim-scripts/SyntaxAttr.vim'
Plug 'guns/vim-clojure-static'
Plug 'StanAngeloff/php.vim'
Plug 'isRuslan/vim-es6'
Plug 'majutsushi/tagbar'
call plug#end()