Given the string "text text #{interpolation}"
Sublime Text 2 highlights the whole string with one color. I would like to highlight the interpolated text so it is easy to pick out. When I press ctrl-shift-alt-p in the interpolated section Sublime tells me the namespace: source.ruby string.quoted.double.ruby source.ruby.embedded.source
给定字符串“text text#{interpolation}”Sublime Text 2用一种颜色突出显示整个字符串。我想强调内插文本,以便于选择。当我在插值部分按ctrl-shift-alt-p时,Sublime告诉我命名空间:source.ruby string.quoted.double.ruby source.ruby.embedded.source
I am wondering where I would define a rule to highlight this(I think in the tmLanguage file), what format that rule would take, and how to go about assigning a color to it.
我想知道在哪里我会定义一个规则来突出显示这个(我认为在tmLanguage文件中),该规则将采用什么格式,以及如何为其分配颜色。
2 个解决方案
#1
10
If you dig into the included Dawn.tmTheme
file (one of the only included themes that does this highlighting properly) you'll find these highlighting rules for String embedded-source
, for some reason some of the themes leave this out completely:
如果你深入了解所包含的Dawn.tmTheme文件(这是唯一包含正确突出显示的主题之一),你会发现String embedded-source的这些突出显示规则,由于某些原因,一些主题完全忽略了这一点:
<dict>
<key>name</key>
<string>String embedded-source</string>
<key>scope</key>
<string>string source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#6F8BBA26</string>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#080808</string>
</dict>
</dict>
#2
6
This is better as it actually highlights the code within the interpolation as normal code, rather than all the same colour.
这更好,因为它实际上突出了插值中的代码作为普通代码,而不是所有相同的颜色。
<dict>
<key>name</key>
<string>Embedded Ruby Punctuation</string>
<key>scope</key>
<string>string punctuation.section.embedded.ruby</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F92672</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded Ruby Source</string>
<key>scope</key>
<string>string source.ruby.embedded.source</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFFBF7</string>
</dict>
</dict>
#1
10
If you dig into the included Dawn.tmTheme
file (one of the only included themes that does this highlighting properly) you'll find these highlighting rules for String embedded-source
, for some reason some of the themes leave this out completely:
如果你深入了解所包含的Dawn.tmTheme文件(这是唯一包含正确突出显示的主题之一),你会发现String embedded-source的这些突出显示规则,由于某些原因,一些主题完全忽略了这一点:
<dict>
<key>name</key>
<string>String embedded-source</string>
<key>scope</key>
<string>string source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#6F8BBA26</string>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#080808</string>
</dict>
</dict>
#2
6
This is better as it actually highlights the code within the interpolation as normal code, rather than all the same colour.
这更好,因为它实际上突出了插值中的代码作为普通代码,而不是所有相同的颜色。
<dict>
<key>name</key>
<string>Embedded Ruby Punctuation</string>
<key>scope</key>
<string>string punctuation.section.embedded.ruby</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F92672</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded Ruby Source</string>
<key>scope</key>
<string>string source.ruby.embedded.source</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FFFBF7</string>
</dict>
</dict>