Two Fold-Related Questions

19 views
Skip to first unread message

Marc van Dongen

unread,
Feb 17, 2012, 2:41:35 AM2/17/12
to vim_use
Dear all,


I've just configured vim for folds and I have two questions.

The first question is as follows. When I use the opening brace ({} or
closing brace (}) to more to the previous paragraph or the next
paragraph, my folds sometimes automatically open. I suspect this may
be because there are paragraphs in the fold. Is there a way to turn
this automatically opening/closing off? E.g. when the cursor is just
after a closed fold (at fold nesting level X), then I'd like the
opening brace to move the cursor to just before the closed fold (at
fold nesting level X).

The second question has got to do with ``entering'' a fold. Years ago
I used an occam folding editor that let you enter a fold. Basically,
this let you edit the contents of the fold in a fresh screen. You
could only edit what was outside the fold if you left the fold. Is
there an equivalent of this facility in vim? (I read the manual pages
but I may have missed this.)

Final information: I'm using folds with the `marker` option, I don't
use `gvim`, and my `vim` is version 7.3 (2010 Aug 15, compiled Feb 16
2012 14:12:54).

Thanks in advance for your help.

Regards,


Marc van Dongen

Christian Brabandt

unread,
Feb 17, 2012, 4:25:47 AM2/17/12
to vim_use
Hi Marc!

On Do, 16 Feb 2012, Marc van Dongen wrote:

> I've just configured vim for folds and I have two questions.
>
> The first question is as follows. When I use the opening brace ({} or
> closing brace (}) to more to the previous paragraph or the next
> paragraph, my folds sometimes automatically open. I suspect this may
> be because there are paragraphs in the fold. Is there a way to turn
> this automatically opening/closing off? E.g. when the cursor is just
> after a closed fold (at fold nesting level X), then I'd like the
> opening brace to move the cursor to just before the closed fold (at
> fold nesting level X).

I think, you almost get what you want, if you set
:set foldopen-=block
This will make the { movements not open the folds. But it won't move to
before the closed fold, but stays on the closed fold, where the
paragraph is.

> The second question has got to do with ``entering'' a fold. Years ago
> I used an occam folding editor that let you enter a fold. Basically,
> this let you edit the contents of the fold in a fresh screen. You
> could only edit what was outside the fold if you left the fold. Is
> there an equivalent of this facility in vim? (I read the manual pages
> but I may have missed this.)

Not exactly possible. Use one of the many NarrowRegion plugins
available, e.g. my NrrwRgn
http://www.vim.org/scripts/script.php?script_id=3075
which opens a selected range of lines in a new buffer and marks the
original buffer non-modifiable.

regards,
Christian

dongen

unread,
Feb 17, 2012, 5:08:13 AM2/17/12
to vim_use
* Christian Brabandt <cbl...@256bit.org> [2012-02-17 10:25:47 +0100]:

Hi Christian,

: I think, you almost get what you want, if you set


: :set foldopen-=block
: This will make the { movements not open the folds. But it won't move to
: before the closed fold, but stays on the closed fold, where the
: paragraph is.

Perfect. Seems to do exactly what I want.

: > The second question has got to do with ``entering'' a fold. Years ago


: > I used an occam folding editor that let you enter a fold. Basically,
: > this let you edit the contents of the fold in a fresh screen. You
: > could only edit what was outside the fold if you left the fold. Is
: > there an equivalent of this facility in vim? (I read the manual pages
: > but I may have missed this.)
:
: Not exactly possible. Use one of the many NarrowRegion plugins
: available, e.g. my NrrwRgn
: http://www.vim.org/scripts/script.php?script_id=3075
: which opens a selected range of lines in a new buffer and marks the
: original buffer non-modifiable.

Thanks. I may see if I can implement it myself.

Regards,


Marc van Dongen

lindsay

unread,
Feb 29, 2012, 1:17:12 PM2/29/12
to vim...@googlegroups.com


On Friday, February 17, 2012 2:08:13 AM UTC-8, Marc van Dongen wrote:
* Christian Brabandt  [2012-02-17 10:25:47 +0100]:

Entering a fold (occam style) is supported by a package by Mario Schweigler


Works very well. Hard to imagine life without it.

Reply all
Reply to author
Forward
0 new messages