I'm forking an old vim plugin (effectively dead since 2018) that needed some love. Once I got to the .vim
file, I noticed that the functions were all defined in there, which made the file unreasonably huge and messy. Is there any way to move these functions to different files for the sake of maintenance?
:h autoload
, for vim9script you can useimport
s see:h vim9-import
autoload/
directory and call them using amy#plg#myfunc()
syntax (assumingmyfunc()
is defined inautoload/my/plg.vim
). For maximum efficiency (during Vim startup), make sure functions from your auto-loaded file will only be called from mappings or user-commands, autocommands, filetype-specific plugins. That way, the autoload file will not be loaded at startup, but only when it's actually needed...