Friday, February 22, 2013

Re: fold on lines beginning with either = or #

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


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