Monday, June 29, 2015

Re: syntax region end when either pattern occurs?

Le lundi 29 juin 2015 à 19:05, Nikolay Pavlov a écrit:
>
>
> 2015-06-29 18:52 GMT+03:00 Rick Dooling <rpdooling@gmail.com>:
> > I am trying to syntax highlight yaml blocks in Markdown files.
> >
> > Right now, I can get it so it handles either blocks that look like this:
> >
> > ---
> > author: me
> > document: Help
> > ---
> >
> > or
> >
> > ---
> > author: me
> > document: Help
> > ...
> >
> > But not both. Is there a way to do both?
> >
> > I tried end=\(/^---$/\|/^\.\.\.$\) but that didn't work
>
> end=\(/^---$/\|/^\.\.\.$\)
>
> Syntax for such items is end={separator}{regex}{separator}[offsets].
> In your example separator is `\` which really results in something
> weird because `\` is *always* an escape character. This has no chances
> to work, you need to use `end=/\v^%(\.{3}|\-{3})$/`.

You can move "{3}" outside the group:

end=/\v^%(\.|\-){3}$/

and since chances are pretty low that you'll have lines mixing "-" and
".", you can use the more relaxed:

end=/\v^[.-]{3}$/

Best,
Paul

--
--
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/d/optout.

No comments:

Post a Comment