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
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.
To enable Syntax Highlighting click on “View” in the top bar, then hover your mouse over “Syntax”, and select your programming language from the list. Alternatively, if you save a document with a supported file extension, Sublime Text 3 will automatically apply the Syntax Highlighting for that language.
🖍 Text Marker (Highlighter)This Sublime Text plugin allows temporarily and persistently marking all occurrences of selected words in a color; multiple marked selections can be added simultaneously, each marking the selections with different colors.
To create a new syntax definition, follow these steps: Go to Tools | Packages | Package Development | New Syntax Definition. Save the new file in your Packages/User folder as a . YAML-tmLanguage file.
For proper syntax highlighting (to tell where the comments are), select JavaScript -> JSON from the option list in the lower right of the Sublime window.
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:
<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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With