Silver Dragon
Silver Dragon

Reputation: 5560

Sublime 2 -changing background color based on file type?

Using an existing Sublime 2 color scheme, is there a way to tweak the background color selectively for eg. .js files only? Many thanks!

Upvotes: 5

Views: 19173

Answers (3)

Michael Nelles
Michael Nelles

Reputation: 6022

For me I wanted to add color scheme to .conf (apache) file

opend myFile.conf in Sublime

Tools > Command Pallet > Set Syntax : groovy

I chose "groovy" you can choose which ever one you want.

Upvotes: 0

Dean
Dean

Reputation: 79

I was actually trying to change the background color for text files and was wondering how Riccardo figured out how to use source.js as the value for the scope.

You need to locate the .tmLanguage file of the file type you are trying to change, which is "Plain text.tmLanguage" for text files. Then look for the scopeName key and use the value for that. This is from my "Plain text.tmLanguage" file:

<key>scopeName</key>
<string>text.plain</string>

So, for example, to change the foreground color for text files to lime:

<dict>
        <key>scope</key>
        <string>text.plain</string>
        <key>settings</key>
        <dict>
            <key>foreground</key>
            <string>#00FF00</string>
        </dict>
    </dict>

Upvotes: 2

Riccardo Marotti
Riccardo Marotti

Reputation: 20348

You have to modify your .tmTheme color scheme plist. You can find it with menu Preferences/Browse Packages..., Color Scheme - Default directory.

You should add something like this:

<dict>
    <key>scope</key>
    <string>source.js</string>
    <key>settings</key>
    <dict>
        <key>background</key>
        <string>#000000</string>
    </dict>
</dict>

as a child of the settings array (of course you have to change #000000 with your color code).

Upvotes: 12

Related Questions