Sublime Forum

Overriding color scheme

#1

Hi,
I am using Monokai Pro color scheme. Is there a way , I can override the color scheme such that the selected text background becomes a color of my choice ? Please see https://cl.ly/8726c447edcf

Following is my color scheme settings

"color_scheme": "Packages/Theme - Monokai Pro/Monokai Pro (Filter Octagon).tmTheme",

Thanks
Gagan

0 Likes

#2

You can do it with Package Resource Viewer:Open Resource and edit the ,tmTheme for that color scheme. Search for ā€œBackgroundā€ (without the quotes).
See also this documentation.

1 Like

#3

You can also create a sublime-color-scheme file in your User package that’s named the same as your color scheme (so in this case the file would be named Monokai Pro (Filter Octagon).sublime-color-scheme) and include in that file only your own adjusted/amended/added rules and global colors.

In that case Sublime will merge your changes on top of the underlying color scheme when it loads, which keeps the original version pristine and only overrides specific things.

There is documentation for the sublime-color-scheme format that will tell you what the file should look like. In your case you would need a globals section that only specifies the appropriate selection setting.

1 Like

#4

I’m not sure it’s a good idea to modify the color theme directly. It’s easier, I think, to simply override the items you want to adjust.

In order to do that, create a XXX.sublime-color-scheme in your Packages/User directory, where ā€˜XXX’ is the color scheme name you want to adjust.

In this file, which follows the JSON format, simply specify the items you want to configure. For example:

{
  "rules": [
    {
      "name": "WordHighlight",
      "scope": "my.wordhighlight",
      "background": "color(var(blue2) alpha(0.5))"
    }
  ],
  "globals": {
    "selection": "red"
  }
}

(In this example, the selection color is forced to be ā€œredā€, and the background for scope my.wordhilight is also tweaked.)

0 Likes

#5

Thanks. It works. But I would also like to change the background of other highlighted words when I press command + d . https://cl.ly/793f648e9130 (for example in the screenshot attached , I would also like to highlight the word innerFoo which currently has a transparent background.

Thanks

0 Likes

#6

I like modifying the color scheme directly. It is quick and easy. If something goes wrong, I just delete the old theme and download it again,

.

0 Likes

#7

I am not familiar with Monokai, and I am not sure if what you want to do is possible. You would probably have to specify the scope name, and I don’t know if the background can be changed except globally. Also, if you want to make many changes to the color scheme, you probably would be better off creating a color-scheme file in your user directory,
Perhaps someone else can help you.

0 Likes

#8

Hi Gagan - Yes you can! But you are edging into Settings. Anyway, here’s theme descriptions for Legacy SpaceCadet.tmtheme. Adjust colors as required. You can comments these things as you go. As far as development goes, online guides may be a little dated, because color scheme developers tend to innovate as they go. E.g., twice extracted Bamboo theme, completely different each extraction. Below, be careful with section Comment and Bracket and beyond (confusing for me down there, where theme creators can over-ride stuff up the top end where I do most of my editing). The three scopes I edit here have to be deleted from further down in file… Note that these color configurations seem to get ignored if JSON and Python things are going on. Otherwise, top end stuff here works with any theme.

SpaceCadet.tmTheme…
<string>SpaceCadet</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<!-- Indent vertical gutter guides -->
<key>guide</key> <!-- guide color default -->
<string>#333333</string>
<key>activeguide</key> <!-- caret guide color -->
<string>#333999</string>
<key>stackguide</key> <!-- caret parent guide color -->
<string>#333666</string>
<!-- Bracket cursor response -->
<key>bracketContentsForeground</key>
<string>#D80E64</string>
<key>bracketContentsOptions</key>
<string>underline</string>
<key>bracketsForeground</key>
<string>#D80E64</string>
<key>bracketsOptions</key>
<string>foreground</string>
<!-- Document Selection -->
<key>caret</key>
<string>#D80E64</string>
<key>lineHighlight</key>
<string>#121522</string>
<key>selection</key>
<string>#1D416B</string>
<key>selectionForeground</key>
<string>#bbccff</string>
<key>selectionBorder</key>
<string>#4D71FF</string>
<key>inactiveSelection</key>
<string>#1D416B</string>
<key>inactiveSelectionForeground</key>
<string>#bbccff</string>
<!-- Search Results -->
<key>findHighlight</key>
<string>#0BD0AC</string>
<key>findHighlightForeground</key>
<string>#000000</string>
</dict>
</dict>
<!-- Comment and Bracket -->
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#407040</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tag</string>
<key>scope</key>
<string>brackethighlighter.default</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#344f7f</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tag</string>
<key>scope</key>
<string>meta.tag, declaration.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#344f7f</string>
</dict>
</dict>

0 Likes