Saturday, February 23, 2013

Re: fold on lines beginning with either = or #

On Friday, February 22, 2013 7:19:06 PM UTC-6, Tim Chase wrote:
> On 2013-02-22 15:14, Rick Dooling wrote:
>
> > Using Fountain (new markdown for screenwriters).
>
> >
>
> > I have Vim successfully folding on lines beginning with =
>
> >
>
> > using this
>
> >
>
> > setlocal foldexpr=getline(v:lnum)!~\"^=\"
>
> >
>
> > but I would like Vim to fold on BOTH = and # (hierarchy not
>
> > necessary)
>
>
>
> I'm not familiar with Fountain, but the "!~" is a "doesn't match
>
> this regexp" operator, so I'm surprised it's folding them
>
> away rather than folding away all lines that *don't* begin with an
>
> "=".
>
>
>
> You should be able to do
>
>
>
> setlocal foldexpr=getline(v:lnum)!~'^[=#]'
>
>
>
> to use a character-class. If they can begin after arbitrary
>
> whitespace, you could also do
>
>
>
> setlocal foldexpr=getline(v:lnum)!~'^\\s*[=#]'
>
>
>
> -tim

Tim,

Of course, I misspoke (mis-wrote). Yes, Vim folds away all lines that DO NOT begin with = and now, thanks to you, also folds away all lines that do not begin with #.

Thank you. I could not see how to form a character class in the foldexpr help sections.

This will be most helpful.

Fountain is just a markup language for screenwriters, which enables us to use our favorite text editor to write screenplays, instead of buying some $200 stand-alone gui screenwriting program.

http://fountain.io/

Thank you again,

Rick

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment