2

I usually edit my files in gVim when developing. Sometimes I need to do a quick tweak in my .vimrc or in some plugins (like snipMate). To do this, I open a terminal, open vim and edit my .vimrc or my plugin.

(Why do I do that, opening .vimrc in a different window? I don't like to mix configuration files with project files when I'm at gvim, it's a matter of preference.)

I would like to have these modifications available at my already opened gVim without restarting it - automatically.

So, my question is: how do I automatically load my .gvimrc/.vimrc after editing it in an already opened gVim session? I use snipmate plugin, is it possible to create a snippet and use it right away as well?

I'm already using this solution

augroup myvimrchooks
au!
    autocmd bufwritepost .vimrc source $HOME/.vim/.vimrc
augroup END

It works, but not in the first scenario I described. Any ideas in how can I do it? Thanks!

Community
  • 1
  • 1

1 Answers1

3

Here's a suggestion. This may need some tweaking. (Also, I'm asuming your .vimrc is in $HOME/.vim/.vimrc rather than $HOME/.vimrc based on how the question was worded.) The idea is to send the :source $HOME/.vim/.vimrc command to every active vim server when .vimrc is written.

 function! UpdateVimRC()
     for server in split(serverlist())
         call remote_send(server, '<Esc>:source $HOME/.vim/.vimrc<CR>')
     endfor
 endfunction
 augroup myvimrchooks
 au!
    autocmd bufwritepost .vimrc call UpdateVimRC()
 augroup END

Probably only works with GVIM, but I'm not sure.

frabjous
  • 1,019
  • 9
  • 13
  • I opened my vimrc in a terminal windows, with gVim opened. When I save the vimrc buffer, I can see the command ":source $HOME/.vim/.vimrc" being called in gVim window, but the modification I made in vimrc weren't available. Do you know what can be? Thanks! – Somebody still uses you MS-DOS Nov 16 '10 at 16:40
  • Well, it seems it's working now. This is a pretty little trick. Thanks for this tip, it isn't trivial, and I'm really lucky to have this answer. Thanks! – Somebody still uses you MS-DOS Nov 19 '10 at 21:51