Sublime Forum

tmLanguage - highlighting nth word differently

#1

Hey, I have the following line in a script file of the Ogre material script language:

texture_ref mrt_gbuffer Deferred/GBuffer mrt_gbuffer_out

Now, what I want to do is highlighting the first word “texture_ref” in one color, the second and final words in a second color and the third word (“Deferred/GBuffer”) in yet another color.
Here is my rule so far:

<dict> <key>comment</key> <string>Texture Reference</string> <key>begin</key> <string>\b(texture_ref)\b</string> <key>beginCaptures</key> <dict> <key>1</key> <dict> <key>name</key> <string>storage.type</string> </dict> </dict> <key>end</key> <string>$</string> </dict>
It does nothing but highlight the first word correctly, as I have no idea how I can highlight single words at the nth position.

Also, I’m using ST3, if that makes a difference.

[size=85]Yes, I know I can use JSON, but all that saving JSON to PLIST, then saving under a different ending, then repeating all the time when doing minor changes just got on my nerves so I’m now sticking to XML.[/size]

0 Likes