vim - Why check did_load_filetypes in custom filetype files? -
from vim wiki:
custom filetype.vim files should have following structure:
if exists("did_load_filetypes") finish endif augroup filetypedetect " au! commands set filetype go here augroup end
i wondering why if...endif part necessary?
i think means if filetypes loaded, skip loading script. in case what's point of creating custom filetype file?
this include guard, avoid custom filetype accidentally sourced multiple times.
if goes well, indeed looks superfluous, variations in user configuration, plugin managers, etc., it's better safe. , saves vim re-processing potentially large list of definitions, speeding startup.
what happens when sourced twice?
if use :autocmd
instead of :autocmd!
, detections defined twice. (note initial :autocmd!
cannot used here clear previous definitions, because multiple filetype.vim
files involved, , each adds existing ones.)
Comments
Post a Comment