Sublime Forum

How to change highlight backgroud/foreground on Mac

#1

I have Sublime Text 3.1.1 Build 3176 on my Mac. I use the Default.sublime-theme theme and the Monokai colour scheme.
I would like to make my selected text a bit easier to see but after searching google, I haven’t found any advice that relates to the installed version I have, and I haven’t been able figure out how to do this.
I don’t have the option to install the PackageResourceViewer. I tried grepping my Sublime install folder for “selection” but nothing came up. I’ve tried using both the Preferences and Command Palette.

0 Likes

#2

The packages that ship with Sublime are stored in sublime-package files (zip file with a different extension), so a grep would not hit anything if you grep the install folder unless you’re using a tool that can look inside archives (and knows that’s what those files are).

Since you’re using a recent Sublime Text you can see the color scheme you’re using without installing anything else by selecting the built in View Package File command from the command palette, then opening Color Scheme - Default/Monokai.sublime-color-scheme (you can filter the list of files by entering monokai). This will open up a read-only copy of the resource (since it’s packed in a sublime-package file) for you to look at.

sublime-color-scheme is one of the Sublime resource files which are combined with similarly named files when they’re loaded, so the best way to tweak the scheme to your liking would be to create a file with the same name in your User folder and put your changes in there.

The files in User are loaded last, so your file there will be overlaid on top of the default. That means that your version of the file only needs to include items that you want to append and items that you want to overwrite.

For example, to change the background color of the selection from the default of grey, your file would look like this:

{
    "globals": 
    {
        "selection": "#FF00FF"
    }
}

The structure of the file is the same as the default, so this changes only the selection key (to a sweet, sweet magenta color) but leaves everything else as is.

For more information on the color scheme format and how it works (and another sample that shows this augmentation process), see the docs on color schemes.

0 Likes

#3

@OdatNurd: Thanks!!!

Creating ~/Library/Application Support/Sublime Text 3/Packages/User/Monokai.sublime-color-scheme and pasting your code into it, did indeed change the highlight colour to magenta. And I didn’t even need to restart Sublime. Cool.

During my searches, I saw that it is possible to change the foreground colour of the selection. Which key would be used for this in ST3?

<key>selectionForeground</key>
<string>#000000</string>

The above would be for an older version I guess, as it wasn’t recognised even after I transformed it to the notation you used.

0 Likes

#4

Generally the rule for converting those items from tmTheme format to sublime-color-scheme format is to convert the names from CamelCase to snake_case instead, so selectionForeground becomes selection_foreground:

{
    "globals":
    {
        "selection_foreground": "#FF00FF"
    }
}

Of course, you can use both at the same time if you want, depending on how much magenta you crave. :wink:

1 Like

#5

Is it possible to put comments into these files?

0 Likes

#6

Yes, you can use /* */ style block comments or // line comments. This is true of all Sublime resource files in JSON format (but note that the contents of Preferences.sublime-settings will get automatically rewritten in some circumstances, which will throw your comments away).

Although the format of the files is JSON, Sublime’s parser is more relaxed than the standard and allows for comments and trailing commas.

1 Like

#7

I usually don’t participate in the forums much - I mostly come here looking for answers. I had exactly the same complaint about the default highlight color being too “soft” - it was just too hard to spot a small highlighted word (IMHO that aspect of Monokai should be changed, the rest is perfect). Anyway, I wanted to say thanks to OdatNurd for contributing his answer.

0 Likes