Reputation: 63
For the syntax highlighting for a language, is there a way to exclude part of the matching used for selection from the actualy highlighting. I want to select variable/function usages such as ".someVariable" but I don't want the "." to actually get highlighted. Just the "someVariable" part. But I need the "." to be part of the matching.
What I have in the tmLanguage file for the specific selection:
<dict>
<key>match</key>
<string>\b\.([-_a-zA-Z0-9]+)\b</string>
<key>name</key>
<string>variable.language.mylang</string>
</dict>
Upvotes: 4
Views: 272
Reputation: 376
You can use captures = {…}
to define names (“scopes”) only for parts of the match. This will work:
{ patterns = (
{ match = '\b\.([-_a-zA-Z0-9]+)\b';
captures = {
1 = { name = "variable.language.mylang"; } ;
};
},
);}
Upvotes: 1