Reputation: 55293
I'm trying to modify the highlight of CoffeeScript comments:
"" coffeescript comments
syntax keyword coffeescriptCommentTodo TODO FIXME XXX TBD contained
syntax region coffeescriptLineComment start=/####\@!/ end=/###/ keepend contains=coffeescriptCommentTodo,@Spell
syntax region coffeescriptEnvComment start=/####\@!/ end=/###/ display
syntax region coffeescriptLineComment start=/####\@!/ end=/###/ keepend contains=coffeescriptCommentTodo,@Spell fold
syntax region coffeescriptCvsTag start="\$\cid:" end="\$" oneline contained
syntax region coffeescriptComment start=/#*/ end="\$" contains=coffeescriptCommentTodo,coffeescriptCvsTag,@Spell fold
I admit I'm doing it a bit randomly, basing myself in this other syntax file:
syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo
hi def link coffeeComment Comment
syn region coffeeBlockComment start=/####\@!/ end=/###/
\ contains=@Spell,coffeeTodo
hi def link coffeeBlockComment coffeeComment
" A comment in a heregex
syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained
\ contains=@Spell,coffeeTodo
hi def link coffeeHeregexComment coffeeComment
With that I have now (the first code), everything looks commented except if statements. How do I modify the syntax file to highlight properly CoffeeScript comments?
Upvotes: 0
Views: 51
Reputation: 326
Doing a search for #*
matches the whole of any file, because the *
matches any number of the preceding character even zero. So all characters match zero #
s.
That's why the example you posted uses #.*
-- match one #
then any number of any character (.*
)
I've found this to be a useful reference: VimRegex.
The offending line is:
syntax region coffeescriptComment start=/#*/ end="\$" contains=coffeescriptCommentTodo,coffeescriptCvsTag,@Spell fold
Try: start=/#\+/
to match at least one #
and any more.
Upvotes: 2