Monday, June 29, 2015

Re: syntax region end when either pattern occurs?

On Monday, June 29, 2015 at 10:52:25 AM UTC-5, Rick Dooling wrote:
> 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
>
> unlet b:current_syntax
>
> " Bring in YAML syntax for front matter
> syntax include @Yaml syntax/yaml.vim
>
> syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/ keepend contains=@Yaml
> syntax region yamlFrontmatter start=/\%^---$/ end=/^\.\.\.$/ keepend contains=@Yaml
>
> let b:current_syntax='markdown'

Thank you so much. It works perfectly. In way over my head but I'll read until I understand how you did it. Many thanks.

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

No comments: