Hello,

* What I want:

Be able to do :w after editing $MYVIRC and have vim source the new
version of config. Basically, just execute `source %` automatically.

* What I have tried (all examples are launched with `vim -u testvimrc`):

So, this works without any error, as supposed:
> set nocompatible
> filetype plugin indent on
> syntax on
> 
> augroup vimrc
>       autocmd!
>       autocmd BufWritePost testvimrc source testvimrc | echom "Reloaded"
> augroup END

However, if I try wrapping it in a function, E127 occurs:
> set nocompatible
> filetype plugin indent on
> syntax on
> 
> augroup vimrc
>       autocmd!
>       autocmd BufWritePost testvimrc call s:ReloadRC("testvimrc")
> augroup END
> 
> function! s:ReloadRC(rc)
>       exec 'source ' . a:rc | echom "Reloaded " . a:rc
> endfunction

Whenever I do :w, I see:
> E127: Cannot redefine function <SNR>1_ReloadRC: It is in use

But at the same time it doesn't abort and I see:
> Reloaded testvimrc
, so it looks like the new vimrc gets sourced regardless?..

* My questions:
1) Why doesn't this work if wrapped into a function, but does, if
written out directly?
2) Why, if an error occurs, I still see "Reloaded testvimrc"?
3) Does it have anything to do with reentrancy?
4) Is it possible to make it work through calling a function (since I
would want to do the same for gvimrc (as well as vimrc), and don't want
to have repetitive code, instead using a reusable function code)?

Thank you in advance.
-- 
Regards,
Oleksii Vilchanskyi
PGP:0x8D3A0E046BDE941F2A53867CE3FD952D48C0B338

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to