> On Di, 21 Aug 2018, Oleksii Vilchanskyi wrote:
>> However, if I try wrapping it in a function, E127 occurs:
>>> set nocompatible
>>> filetype plugin indent on
>>> syntax on
>>> augroup vimrc
>>> autocmd BufWritePost testvimrc call s:ReloadRC("testvimrc")
>>> augroup END
>>> function! s:ReloadRC(rc)
>>> exec 'source ' . a:rc | echom "Reloaded " . a:rc
>> Whenever I do :w, I see:
>>> E127: Cannot redefine function <SNR>1_ReloadRC: It is in use
> Yes, what happens when you execute the function is, you reload your
> .vimrc which will redefine your function, while the function is
> executed. This is not allowed and causes the error message. Either do
> not use a function, or define your function inside e.g.
> ~/.vim/plugins/reload.vim or similar.
Thank you, the very day I sent the mail people on IRC showed me an
example of how this can look as a plugin (basically, copy all the
information regarding that into a plugin and put it under the guard),
just as you suggested. So, I ended up with this:
Although with the code above, I have noticed that whenever I run gvim,
neither vimrc nor gvimrc get sourced when I edit gvimrc, but both get
sourced if I edit vimrc. With terminal vim it's the same -- if I edit
vimrc, it gets sourced (and only it, since it's terminal vim), if I edit
gvimrc, nothing gets sourced. So, I suspect there is some issue with
> autocmd BufWritePost $MYGVIMRC call s:ReloadRC()
, looks like the condition is not getting triggered, or I don't
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.