For editing XML files I have the following in my init.vim
" Automatically enable folding of XML-files augroup XML autocmd! autocmd FileType xml let g:xml_syntax_folding=1 autocmd FileType xml setlocal foldmethod=syntax autocmd FileType xml :syntax on autocmd FileType xml :%foldopen! augroup END
This is fine for small files. From times to times I will edit large (huge) XML-files which open much faster without folding.
My way of doing is to open an new buffer,
set ft=xml # Which yields an error message because the buffer is empty and no folds can be found setlocal foldmethod=manual :r <file>
Is there a better way of disabling folding for a buffer before the file is loaded?