开发者

Automatically reload .vimrc edited in a vim session in an already opened gVim instance?

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 ter开发者_如何学Pythonminal, 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜