confused about folds

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

confused about folds

Ross Boylan
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.
--
Ross Boylan                                      wk:  (415) 514-8146
185 Berry St #5700                               [hidden email]
Dept of Epidemiology and Biostatistics           fax: (415) 514-8150
University of California, San Francisco
San Francisco, CA 94107-1739                     hm:  (415) 550-1062

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: confused about folds

Steve Litt
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
_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: confused about folds

Ross Boylan
On Mon, 2006-08-28 at 18:18 -0400, Steve Litt wrote:
[nice explanation snipped]
>
> 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.
That's a good guide.  I started wondering about this because I wanted,
effectively, to apply folding levels to a subpart of an outline.  For
example, given
A
   B
      C
         D
            E
      F
         G
         H

suppose I want to move to
A
   B
     C
     F
with the rest folded (where this is part of bigger outline, so I can't
just set the foldlevel globally).  Is there a good way to do that?

I was trying to get this working with some combination of folding
commands from B, but don't see a way around manually closing C and F.

Or could I hoist the relevant section, set the foldlevel, and then
revert?  When I try, the folding seems to be lost when I go back to the
main outline.

The general capability I'm looking for is setting the fold-level (like
\3 or ,,3 depending on prefix) for a suboutline.

Ross


_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner
Reply | Threaded
Open this post in threaded view
|

Re: confused about folds

Steve Litt
On Monday 28 August 2006 06:45 pm, Ross Boylan wrote:

> On Mon, 2006-08-28 at 18:18 -0400, Steve Litt wrote:
> [nice explanation snipped]
>
> > 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.
>
> That's a good guide.  I started wondering about this because I wanted,
> effectively, to apply folding levels to a subpart of an outline.  For
> example, given
> A
>    B
>       C
>          D
>             E
>       F
>          G
>          H
>
> suppose I want to move to
> A
>    B
>      C
>      F
> with the rest folded (where this is part of bigger outline, so I can't
> just set the foldlevel globally).  Is there a good way to do that?

Hi Ross,

I bet dollars to donuts there's a way, but I couldn't find it. Try :h fold and
read all the docs and experiment -- U might find a way. That's the way I
figured out the comment method of body text.

If you can't find a way, ask the list what keystroke command they think should
do that, and then create a Vim language function to do it. If U can't do
that, remind me in late September when I have more time, and I can do it. By
the way, look over Noel's Vim code -- there's a lot of really good stuff in
there. Whenever I want to do something in Vim code, I find some of Noel's
code that does something similar, and hack it til it does what I want.

HTH

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

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner