Monday, March 2, 2015

Re: syntax highlighting for class names

Le dimanche 01 mars 2015 à 10:07, Mark Volkmann a écrit:
> Thanks Paul! I'm probably close now, but not quite there. Do you see anything wrong with this?
>
> syntax keyword jsClassKeywords class extends contained
> syntax region javaScriptClassName start=/^class \| class /hs=e+1 end=/ /he=s-1 "contains=jsClassKeywords

First, your "contains" keyword in the second line is commented out.
Second, ending the region with a space is ill-advised (even though, to
be honest, I don't understand why the region stops at the space after
"class", given that start and stop patterns aren't supposed to
overlap ... anybody?). An opening brace is the right way to go.
Finally, but that's just personal preference, if you don't need a
region, use a simple match:

syntax match javaScriptClassName +^\s*class.\+i\ze{+ contains=jsClassKeywords

If you really want a region:

syntax region javaScriptClassName start=+^\s*class+ end=+{+me=e-1 contains=jsClassKeywords

I hope that'll be what you want.

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: