Is there a good way to use folding with "plain text" files?
But what do I mean by "plain text"?
I'm thinking of text like it is used in human communication when no formal structure is required.
It has some ad-hoc structure, like paragraphs, indentation changes, maybe ranges of cited lines.
But with no clear rules.
It's certainly possible to use folding for this kind of text: it can be done manually.
I am looking for ways to make that easier.
One way to answer this could be to use a plugin that provides a set of support functions, used loosely together.
They could implement things like
- handling folding for structured sections of text, while tolerating the other parts
- check or enforce rules of some kind of minimal structure
- support restructuring of the text
A different approach, related to the third item, would be to require to change the text to be more structured.
With this, a valid, but suboptimal solution is to require the user to reformat the text to Markdown, and then use a standard Markdown filetype plugin to handle the folding.
$any
file format. I do so in one of my scripts; there are also some folding functions (:help folding-functions
); you can combine this to create a complex set of rules to be "smart" about what Vim should fold, I'm not sure if this will actually work very well (but it could perhaps do), but such thing is certainly not trival to do, and IMHO beyond the scope of an answer here..zf
) or by indenting (>
) as they read. I don't understand how a script could make this simpler.