Sublime Forum

Different bg colour for different languages within same file

#1

Hello,

I’ve noticed that some of the colour schemes that come with Sublime Text use different background colours for different languages in the same file- examples being Cobalt and Espresso Libre. This is very handy when editing PHP with inline HTML, or HTML with inline CSS and JavaScript. I’d like to be able to bring this to some other colour schemes, but I can’t for the life of me see what I am supposed to add to the .tmTheme files.

Can someone point me in the right direction for this?

Thanks in advance.

P.S. I’m English, and that is the correct spelling of ‘color’ over here. :smile:

0 Likes

#2

Hi, if I understood your question,
what you’re asking for is pretty simple, and it’s done by adding a background node (and of course a #rrggbb node too) in the scope you want to modify; to better understand this just take a look at Cobalt colour scheme, search for “Invalid” scope and you’ll find both back and foreground set in there, while the previous scope “Function Call” only has foreground setted.
Example:
with regular bg

<dict> <key>name</key> <string>Function Call</string> <key>scope</key> <string>meta.function-call</string> <key>settings</key> <dict> <key>foreground</key> <string>#FFEE80</string> </dict> </dict>
with modified bg

<dict> <key>name</key> <string>Function Call</string> <key>scope</key> <string>meta.function-call</string> <key>settings</key> <dict> <key>foreground</key> <string>#EE8FF0</string> <key>foreground</key> <string>#FFEE80</string> </dict> </dict>

Hope it helps :wink:

0 Likes