[Vimoutliner] confused about folds

Steve Litt slitt at troubleshooters.com
Mon Aug 28 18:18:53 EDT 2006


On Monday 28 August 2006 03:37 pm, Ross Boylan wrote:
> I've been using vo for quite awhile without ever quite understanding
> folds and the zo, zO, zc, zC commands.  I think I don't quite have the
> mental model.  I'd appreciate any help or pointers; I have
> reviewed :help fold and usr_28.txt.
>
> Many things that I expect to operate down operate up.  Perhaps the first
> sign of trouble was in user_28:
> ------------------------------
> Folds can be nested: A region of text that contains folds can be folded
> again.  For example, you can fold each paragraph in this section, and
> then fold all the sections in this chapter.
> ------------------------------
> The nesting here appears to be outward, whereas I think of smaller
> sections nesting inside of bigger ones.  The manual proper refers to
> zC              Close all folds under the cursor recursively
> "Under" to me means physically under, which is also conceptually under
> (a subpart).  But the actual behavior appears to be up.
>
> Consider this file
> A
>     B
>     C
>         c1
>         c2
>             c2a
>             c2b
>
>
> On c2a, zc collapses up to c2; I would expect it to be a no-op.
> On c2, zc collapses c2a and c2b, as I would expect.
>
> On C, zc collapses all the subparts.  The reference says
> "zc Close one fold under the cursor.  When a count is given, that
> many folds deep are closed."  This makes no sense to me; it seems to say
> that zc will close c1 and c2, but leave c2a and c2b open.
>
> On c1, ZC collapses all the way *up* to A.  zc with arguments collapses
> up the tree to varying extents.

Hi Ross,

IMHO don't pay too much attention to the "whys" of zo, zc, zO and zC. The VO 
developers didn't specify or implement them. We simply piggybacked on what 
Vim already did.

I too don't exactly understand the workings of zo, zc, zO and zC. I've just 
gotten used to them, similar to how you get used to driving a car whose 
steering wheel pulls to the left, or whose accellerator stalls if you push it 
too hard or suddenly.

The preceding paragraph does not imply anything wrong with Vim's way of doing 
it. In fact, I think it's really convenient. On an expanded parent, zc closes 
its children into itself. But on a leaf node or a collapsed parent, zc 
collapses itself and its siblings into its parent. 

What this gives you is the ability to repeatedly zc until you've collapsed to 
the desired level. Back in the old days, when Vim did nothing if you zc on a 
leaf or collapsed parent, you'd need to repeatedly j up to the parent, over 
and over again. I was extatic when Vim changed it.

Interestingly, in earlier versions of Vim, zc did what you thought intuitive 
-- it closed below itself but left its siblings and parent alone. Then Vim 
changed to collapse sibs into the parent if zc was done on a leaf or 
collapsed parent, and I rejoiced in the convenience.

zC closes all the way up to the level 1 superparent. I don't think that's 
expecially useful, but if you need it, it's there.

zo reveals all children of the current headline. If those children were 
collapsed before the last zc, they're collapsed after the zo. If they were 
expanded before the last zc, they're expanded after the zo.

zO on a collapsed headline completely expand all its descendents, regardless 
of their history. zO on an expanded headline does nothing, strangely. If you 
want to completely open a partially open headline, zc followed by zO does the 
trick.

In summary, VO's headline expand and collapse keystrokes don't necessarily 
reflect the concepts of outlining, but they sure are convenient. I think 
they're brilliant.

SteveT

Steve Litt
Author: 
   * Universal Troubleshooting Process courseware
   * Troubleshooting Techniques of the Successful Technologist
   * Manager's Guide to Technical Troubleshooting
   * Twenty Eight Tales of Troubleshooting
   * Rapid Learning: Secret Weapon of the Successful Technologist

http://www.troubleshooters.com/bookstore
http://www.troubleshooters.com/utp/tcourses.htm


More information about the VimOutliner mailing list