I have a function that I would like to run once and do nothing in subsequent calls to it. It handles lazy-loading of plugins.
function! LoadExpensivePlugins()
call StuffToRunOnceOnly
" what do i do here?
endfun
I have a function that I would like to run once and do nothing in subsequent calls to it. It handles lazy-loading of plugins.
function! LoadExpensivePlugins()
call StuffToRunOnceOnly
" what do i do here?
endfun
The simplest solution is simply to set a variable:
let s:LoadExpensivePluginsHasBeenRun = 0
function! LoadExpensivePlugins()
if !(s:LoadExpensivePluginsHasBeenRun)
call StuffToRunOnceOnly
let s:LoadExpensivePluginsHasBeenRun = 1
endif
endfun
:delfunction
as an answer, it seems more directly answering my original question.
– Steven Lu
Feb 16 '17 at 21:40
E127: Cannot redefine function LoadExpensivePlugins: It is in use
– Steven Lu Feb 16 '17 at 19:06:delfunction
(this won't work from within the function however (as you noted)) – Christian Brabandt Feb 16 '17 at 19:25:delfunction
. Thank you.... – Steven Lu Feb 16 '17 at 21:40