This can be very useful, I'm going to show how to reload your vim configs anytime you save them or using a command and a map.
Make your configs reloadable
! on your commands and functions like this:
function! ToggleLineNumbers() if &number == 1 set nonumber else set number endif endfunction command! GoToDefinitionUsingCTags execute ':tag ' . expand("<cword>")
! means that you are overwriting the function/commands if it is already loaded.
Option #1: Auto command
When using an auto command, vim is going to source -- or reload -- your vim configs every time you save them.
" the BufWritePost event gets triggered after writing buffers to files autocmd! BufWritePost *.vim* so $MYVIMRC
$MYVIMRC is the path to your
More on auto commands: Introduction to vimL for vimmers
Option #2: Command and map
When using a command, vim is also going to source your configs, but only when you call the command.
command! ReloadVimConfigs so $MYVIMRC \| echo 'configs reloaded!'
After adding it to your vimrc, you need to type
I prefer this option because I have more control over when my configs are reloaded.
You can create a map for that:
map <C-r> :ReloadVimConfig<CR>
That's all, hope you enjoyed. Any problems or questions? Please reach out on twitter and I can help you out.