Reputation: 107
I have code like this:
# some comment
comment This is a comment \
that continues.
keyword option=3.123e4
Comments start with either "#" or "comment" and can continue with "\" and a line break. I would like to match the next line after the last "\" as well or until a keyword from the list. Here is what I have:
syn match atlasComment "#.*$"
syn match atlasComment "comment.*$"
syn keyword myKeyword keyword anotherKW nextgroup=myOption skipwhite
syn keyword myOption option
Is it possible to use a range from "comment" to a specifiet keyword from list of keywords that are highlighted anyway? Or is there a better way?
Upvotes: 1
Views: 191
Reputation: 172550
You'll find some useful hints at :help :syn-oneline
.
The "oneline" argument indicates that the region does not cross a line boundary. It must match completely in the current line. However, when the region has a contained item that does cross a line boundary, it continues on the next line anyway. A contained item can be used to recognize a line continuation pattern.
This leads to the following solution:
:syn region atlasComment start="comment" end="$" oneline contains=atlasCommentContinuation
:syn match atlasCommentContinuation "\\$" contained
Upvotes: 1