Sublime 2 -changing background color based on file type?

后端 未结 3 1133
你的背包
你的背包 2021-01-13 06:52

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

相关标签:
3条回答
  • 2021-01-13 07:18

    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).

    0 讨论(0)
  • 2021-01-13 07:25

    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>
    
    0 讨论(0)
  • 2021-01-13 07:34

    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.

    0 讨论(0)
提交回复
热议问题