If you find yourself always re
:so ing your vimrc after you changed it, have the following autocmd in your vimrc:
autocmd! bufwritepost .vimrc source %
I did this and it seems to work. However I get a lot of errors (E174) saying command already exists for each line in my vimrc.
When you define functions in vimrc, use "function!". Some other commands should also have "!" appended, which means to overwrite the existing command.
expand('<sfile>') helps to find the .vimrc name.
For example, since I switch between Windows and Linux, my .vimrc contains:
exec 'cab vimrc' . expand('<sfile>')
Even better, put in your .vimrc:
autocmd BufWritePost .vimrc source %
And in your .gvimrc:
autocmd BufWritePost .vimrc source % source ~/.gvimrc autocmd BufWritePost .gvimrc source %
The gvimrc part still has ~/.gvimrc hard-coded, though.