Is it a matter of source
-ing the file as I am editing it?
Yes! :so %
should do the trick when you're editing your vimrc
. Or you can also use the special variable $MYVIMRC
to access it from anywhere. I have a mapping like the following:
nnoremap <F5> :source $MYVIMRC<CR>
Caveats:
There are a few things you need to do to your vimrc
to make sure you can re-source
it safely.
- Make sure all your functions start with
function!
. The !
makes a re-declaration of the function simply overwrite the function without a warning.
- If you have any
autocmd
s, make sure you include them in a group and start the group with au!
. This will make sure that you don't set up your autocmd
s more than once. And if you edit one, it will delete the old instance.
Example:
augroup MyAutocmds
au!
autocmd...
autocmd...
augroup END