Sublime Forum

tmLanguage - Variable in a string

#1

Hi,

is it possible to display variables inside a string with a different color?

[code]
name
string
match
“’].*?”’]

	<dict>
		<key>name</key>
		<string>variable.parameter</string>
		<key>match</key>
		<string>\$[A-Za-z_][A-Za-z0-9_]*</string>
	</dict>[/code]

Atm it looks like:
$test = “$drive:$folder”;

And I’d want it to look like:
$test = “$drive:$folder”;

=> Variables in strings should have a precedence over the string color itself.

Is that possible?

0 Likes

#2

Yes, Add this:

[code]
captures

2

name
string.quoted.xys

1

name
punctuation.quote.double

4

name
punctuation.quote.double


name
quoted.string.line.xys
match
(")((^"]|"")*)(")

    <dict>
        <key>captures</key>
        <dict>
            <key>1</key>
            <dict>
                <key>name</key>
                <string>label.xys</string>
            </dict>
            <key>2</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.label.xys</string>
            </dict>
        </dict>
        <key>name</key>
        <string>label.line.xys</string>
        <key>match</key>
        <string>^(^: ]+)(:)\s</string>
    </dict>[/code]

But personally, this make .xys files too much colorful → distractive. I’d rather stay with your atm

0 Likes