Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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 Jul 22 '13 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 Jul 23 '13 at 1:32
add comment

1 Answer 1

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
share|improve this answer
    
It's not working either. –  jviotti Jul 22 '13 at 19:55
    
@jviotti - how about this instead? I've updated my answer with another technique I found on SU. –  slm Jul 23 '13 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 Jul 23 '13 at 12:17
    
@jviotti - ughh. I'll keep looking. –  slm Jul 23 '13 at 12:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.