I'm trying to modify an existing language definition that defines comments like this:
<dict>
<key>match</key>
<string>(#) .*$\n?</string>
<key>name</key>
<string>comment.line.number-sign.myLanguage</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.comment.myLanguage</string>
</dict>
</dict>
</dict>
This ensures that a line starting with a #
will be identified as a comment and highlighted accordingly. What I would like to do is surround a commented word in asterisks and have it show up as some other thing, a keyword
for example. But simply appending this doesn't work:
<dict>
<key>match</key>
<string>\*([^*]+)\*</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>keyword.myLanguage</string>
</dict>
</dict>
</dict>
However, it does work if the line doesn't start with a #
, so I'm assuming there is a conflict between both rules. So, I thought I could get around it by using a regex that identifies everything in the comment that isn't surrounded by *
, something like:
# This is a comment *this is something else* this is still a comment *not* yes
Any ideas?
Ok, I got it to work: