Saturday, June 18, 2011

Re: Exasperated with folding

On Jun 17, 2011, at 12:28 PM, Gary Johnson wrote:

> On 2011-06-17, Eric Weir wrote:
>
>> I wonder, also, how this way of doing it would be affected by
>> editing of an entry at a later date. Would it change the date of
>> the fold?
>
> That's one of the advantages to using expression folding instead of
> manual folding. The folded region is determined automatically (in
> this case by a regular expression) and will adjust as you edit the
> file.
>
> The date won't be affected unless you change it yourself.

I don't understand this, but it's reassuring. To understand I'd have to give it a try.

> One disadvantage of this method is that writing the correct
> expression can be tricky....
>
> Alternatively, you could choose some simple pattern for your header
> lines for which it would be easy to write an expression. For
> example, if you used a header line like this,
>
> - Friday, 17 June 2011 -
>
> the pattern could be simply
>
> ^-.*-$
>
> (a hyphen at the beginning at at the end of the line) which would
> make your modeline this:
>
> vim: foldmethod=expr foldexpr=getline(v\:lnum)=~'^-.*-$'?'>1'\:'1'

That simple header is close to what I use now. I just order the items differently.

> You can read more about this here:
>
> :help 28.8
> :help fold-expr
> :help pattern.txt

Will do.

And thanks,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA USA
eeweir@bellsouth.net


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: