5

Automatic folding with the vimtex plugin is unbearably slow.

Is there anything I can do to speed this up? I tried installing the fastfold plugin but that did nothing I could notice.

9
  • Sorry, what's your actual question? Commented Feb 9, 2016 at 12:04
  • 1
    Do you want manual and persistent folds? Or do you want to speed up vimtex? These are two different questions... Commented Feb 9, 2016 at 12:19
  • 1
    I like fold markers
    – Steve
    Commented Feb 9, 2016 at 12:22
  • 2
    You can save folds over sessions with mkview and loadview. See Can I save folds?
    – Steve
    Commented Feb 9, 2016 at 12:25
  • 1
    Okay; I edited your question to only include the vimtex question. For the other one see: Can I save folds? Commented Feb 9, 2016 at 12:31

1 Answer 1

9

First: Did you bother to read the vimtex documentation, i.e. :h vimtex-folding? The docs clearly point out that the fold-expr method of folding is slow, and so therefore provides an option g:vimtex_fold_manual which if enabled (set to nonzero value) will set foldmethod=manual, and instead will remap zx and zX to recalculate the folds when necessary (typically not very often).

The fastfold plugin is a very good alternative, as it will automatically ensure that the foldmethod is set to manual. This will also work for other file types, and the plugin provides a set of possibilities for when the folds should be refreshed.

Disclaimer: I am the developer of vimtex.

5
  • sorry, I saw it but didn't understand it. I still have two problems with the package, though (for which thanks): first, that it doesn't show the number of lines in a fold, which I find useful; and secondly that using it it takes quite long to load a file. for these reasons I'll stick to markers, which I discovered today.
    – Toothrot
    Commented Feb 9, 2016 at 20:54
  • You can use standard foldtext with set foldtext=, which should show line numbers. Also, I personally don't have any problems with long load times that I've noticed. You could consider to open an issue and explain the problem and how to reproduce. Commented Feb 10, 2016 at 8:29
  • This worked out of the box for me. Very nice!
    – Astrid
    Commented Aug 8, 2017 at 0:05
  • You can try using foldmethod=marker. Of course, then you'd have to use a foldmarker (e.g. {{{,}}} or F{O{L{D,F}O}L}D) in tex documents, but it does make it faster.
    – mahbubweb
    Commented May 20, 2020 at 20:03
  • I suggest that you do not use markers for folding tex files, especially if you work together with others, as it makes a lot of unnecessary noise. IMHO, folding in vimtex should be fast enough. I also suggest using vim-FastFold, which is a general purpose and better implementation of the mechanisms provided by g:vimtex_fold_manual. Commented May 21, 2020 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.