I noticed that when functions in plugin/myplugin.vim
are named using the autoload convention, function! myplugin#myfunction()
, the file autoload/myplugin.vim
gets sourced on vim
startup, even though no function of that file is ever called during the startup process. This happens for example with vim-peekaboo. Changing the functions peekaboo#{on,off}
to e.g. Peekaboo_{on,off}
fixes the issue, but I was wondering whether this was documented behavior? Also, is there a canonical way of naming functions in plugin/myplugin.vim
?
1 Answer
Untested, but my theory is that during startup the definition of a function (particularly using function!
) causes vim to check if a function by that name is defined, and this in turn causes the autoload search.
Feedback from contributors to vim would be welcome, in order to decide whether this is a bug or a feature.
function!