1

My vim configuration lives in $HOME/.vim/vimrc, which is symlinked to ~/.vimrc.

Inside my vimrc I have:

if has("autocmd")
  autocmd bufwritepost vimrc source $HOME/.vim/vimrc
endif

But is not working. I also tried sourcing $MYVIMRC.

Am I missing something?

2
  • Can you explain by "it's not working" what isn't working. I'm a little confused as to what you're expecting this to do.
    – slm
    Commented Jul 22, 2013 at 20:42
  • It should source vimrc after I save it, loading the configuration without having to restart vim. The problem is that is not sourcing the file. Tried several paths with :so [vimrc-path]
    – jviotti
    Commented Jul 23, 2013 at 1:32

1 Answer 1

2

This should do it:

augroup myvimrc
    au!
    au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END

Found this solution on SuperUser in Q&A titled: How do you reload your .vimrc file without restarting vim?.

See help on autocmd-patterns for more info:

:help autocmd-patterns
4
  • It's not working either.
    – jviotti
    Commented Jul 22, 2013 at 19:55
  • @jviotti - how about this instead? I've updated my answer with another technique I found on SU.
    – slm
    Commented Jul 23, 2013 at 3:20
  • It didn't work either. I think the problem is on the vimrc path. Manually doing :so $MYVIMRC should work. Tried includign the path: :so $HOME/.vimrc, :so $HOME/.vim/vimrc, :so $MYVIMRC , etc. Nothing seems to find my configuration file
    – jviotti
    Commented Jul 23, 2013 at 12:17
  • @jviotti - ughh. I'll keep looking.
    – slm
    Commented Jul 23, 2013 at 12:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .