On Thursday, January 8, 2015 at 8:04:18 PM UTC-6, Bao Niu wrote:
>
> Thanks Ben, I will conform to the convention and won't top-post in future.
> By 'storing' I actually did not refer to persisting, but temporary. When I use foldmethod=expr to automatically fold up my classes, the foldlevel must be 'stored' somewhere, or otherwise after I switch to manual it would have been all lost. Is there something I'm wrong about this model? Then where does Vim temporarily store such thing? Enviroment variables? Or something?
The idea with using a fold expression is that you won't NEED to switch to manual mode. All your folds would be defined automatically by the function you write.
When you switch fold method, Vim knows in its own internal window state where folds are, and it just keeps them around to initialize the manual folding. There is no associated buffer or user-accessible variable containing all the folds, but you can figure them out using the foldlevel(), foldclosed(), foldclosedend() functions.