Auto Source vimrc When Saved

serhatteker profile image Serhat Teker Originally published at tech.serhatteker.com on ・1 min read

If you find yourself always executing :so after every vimrc change, put this in your .vimrc.

autocmd! bufwritepost .vimrc source %

This causes Vim to automatically source and apply your changes to your vimrc when the buffer is saved.



It will be better option to use variable, since your .vimrc file may be different: For instance if you use NeoVim your rc file is init.vim.

" Automatically source vimrc on save.
autocmd! bufwritepost $MYVIMRC source $MYVIMRC


I want to see a confirmation from Vim after my file sourced to ensure everything is OK. In order to make this happen you can use below snippet:

autocmd! BufWritePost $MYVIMRC source $MYVIMRC | echom "Reloaded $NVIMRC"

All done!

Posted on by:

serhatteker profile

Serhat Teker


Uomo Universale | Software Engineer | Entrepreneur | builds systems | py:js:go |


markdown guide