Evaluate Vim configs with a minimal vimrc

Published:

As one’s .vimrc grows it can become daunting to try new settings out, or to debug an issue in your existing config.

To address this, we can use a feature in Vim that allows us to start a session with a different config:

$ vim -u [path/to/config]

Now we can easily evaluate Vim configs without touching our existing .vimrc.

For example, to quickly see how highlighting trailing whitespace would look, you could create a .minivim containing the following:

" .minivim
set nocompatible          " disable compatibility with Vi - i.e. use Vim's improvements
filetype plugin indent on " detect filetypes
syntax on                 " enable syntax highlighting

" highlight trailing white space
highlight ExtraWhitespace ctermbg=197 guibg=red
match ExtraWhitespace /s+$/

and then start Vim using this new config:

$ vim -u .minivim

To quickly evaluate changes to your config, source the file from inside Vim:

:source .minivim