vim Automatically reload vimrc upon save


Example

To automatically reload vimrc upon save, add the following to your vimrc:

if has('autocmd') " ignore this section if your vim does not support autocommands
    augroup reload_vimrc
        autocmd!
        autocmd! BufWritePost $MYVIMRC,$MYGVIMRC nested source %
    augroup END
endif

and then for the last time, type:

:so $MYVIMRC

The next time you save your vimrc, it will be automatically reloaded.

nested is useful if you're using vim-airline. The process of loading airline triggers some autocommands, but since you're in the process of executing an autocommand they get skipped. nested allows triggering nested autocommands and allows airline to load properly.