Home Download Buy Blog Forum Support

Different bg colour for different languages within same file

Different bg colour for different languages within same file

Postby Godwhacker on Mon Dec 23, 2013 2:46 pm

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. :)
Godwhacker
 
Posts: 2
Joined: Tue Jul 30, 2013 8:48 pm

Re: Different bg colour for different languages within same file

Postby Orlmente on Mon Dec 23, 2013 3:33 pm

Hi, if I understood your question,
what you're asking for is pretty simple, and it's done by adding a <key>background</key> node (and of course a <string>#rrggbb</string> 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
Code: Select all
      <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
Code: Select all
      <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 ;)
Orlmente
 
Posts: 96
Joined: Mon Mar 18, 2013 12:37 pm


Return to General Discussion

Who is online

Users browsing this forum: observingly, prmaple and 28 guests