Vim: show subfold headers inside closed folds

0

Is it possible to show the headers of all subfolds under their respective parent folds in vim? This would be incredibly useful, for example when writing latex, where the document may have 4-5 levels of folds, and you want to get a quick overview of the outline. For example, it would be nice to see output like this:

  2 +--342 lines: \chapter{Methodology}--------------------------------------
  6 +---210 lines: \section{some section}------------------------------------
 46 +---- 12 lines: \subsection{some subsection}-----------------------------
 58 +----158 lines: \subsection{some subsection}-----------------------------
216 +---197 lines: \section{some other section}------------------------------
279 +---- 42 lines: \subsection{some other subsection}-----------------------

and, ideally, to be able to open and close those sections without opening the parent section.

naught101

Posted 2012-06-18T03:46:37.400

Reputation: 911

You can define your own function to show the fold text that you prefer and set the foldtext option to it. See :help fold-foldtext for an example. – Raimondi – 2012-06-18T04:37:55.660

Thanks for the pointer @ElIsra, but I'm not very familiar with the vim language yet. I'll see what I can do, if I find time, but if someone else posts such a function, I'd probably accept that answer. – naught101 – 2012-06-18T08:04:38.327

The problem with your idea is that subfolds, being contained within other folds, are not supposed to be visible at all. That's the point of a fold: closing a fold hides everything within this fold's boundaries. Are you looking for an outlining system?

– romainl – 2012-06-18T08:27:53.280

@romainl: thanks for the link. That looks like overkill to me, and not quite what I wanted, but I will try it. I know folds weren't intended this way, but that's not really a good reason not to try it. – naught101 – 2012-06-19T00:10:27.380

Also, VOoM doesn't appear to like partial latex files (I submitted a bug)

– naught101 – 2012-06-19T04:38:11.133

No answers