1

Often I will have very long static variables at the top of a file, for example a mapping COUNTRY_TO_ISO. I usually fold those mappings with foldemethod=manual. For example:

enter image description here

However, when I save the file, exit it, and re-open it, the folds seem to have disappeared and do not save (even doing zm / zr doesn't change anything). Why don't the manual folds save by default and how can I make it such that when I open a file it automatically collapses any folds?

David542
  • 2,445
  • 14
  • 50
  • Just a note that the autocommand approach to save/loading views has bitten some folks before when settings were being adjusted that the view overrode. Be careful! – D. Ben Knoble Jun 23 '20 at 11:19
  • @D.BenKnoble while approach to folds would you suggest? The files I usually work with are python, and often the folds won't be class/def-based. – David542 Jun 23 '20 at 16:10
  • 1
    I probably go against the grain here, but I use marker for personal stuff, syntax/indent only occasionally (they’re usually slow for me), and I have custom expressions for some things (markdown headers). But I rarely use folds... my recommendation was really to encourage a more manual use of the view commands so you don’t run into spooky action at a distance/hard-to-debug issues – D. Ben Knoble Jun 23 '20 at 16:15
  • I must be traveling the same grain-tangential path as DBK (except I use syntax/indent even less): markers for ad-hoc folding or, for a couple file types, custom expressions. But generally I just don't use them all that much...though that's up from "never" not too long ago. – B Layer Jun 23 '20 at 21:31
  • @D.BenKnoble cool, I got it to work as well, and then updated to provide a more general answer in the linked-duplicate question: https://vi.stackexchange.com/a/26186/28904. – David542 Jun 24 '20 at 03:56

0 Answers0