Change highlight colour in Sublime Text 3?

37,560

Solution 1

You can see which theme you are using by going to

Preferences>Colour Scheme

and see which one is ticked.

Open the theme file and find the key that says:

<key>selection</key>

Go to a site that shows hex colour codes (like this one http://html-color-codes.com/) and find the code for the colour you want. Then sub your new colour code into the line below the selection key in the theme file, replacing the old hex colour code.

Save the modified theme file and it should work straight away.

EDIT
Install PackageResourceViewer plugin using package control. Open the command palette with P (for windows/linux CtrlShiftP) and type prv to get the PackageResourceViewer options. Choose Open Resource >>Theme- YourTheme >> and edit your theme file

Solution 2

Tony Vincent's answer is excellent, and I would also add that if changing the selection color makes the selected text difficult to read, selectionForeground is the key to change. For example:

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

Solution 3

With the new .sublime-color-scheme format, it's a global setting key named line_highlight e.g.

{
    "name": "My colour scheme",
    "globals":
    {
        "background":     "rgb(0, 0, 0)",
        "foreground":     "#aaaaaa",
        "caret":          "red",
        "line_highlight": "#222222"
    },
}
Share:
37,560
erdembayar
Author by

erdembayar

Updated on July 09, 2022

Comments

  • erdembayar
    erdembayar almost 2 years

    How can I change the default highlight colour in Sublime Text 3? I used to know how find a highlight key in one of the theme files in ST2 but things changed quite on ST3. Are they in the library somewhere? "Preference >> Browse Package" is almost empty.

  • erdembayar
    erdembayar almost 8 years
    Where is that theme file? Above was true for Sublime 2. But I don't see theme files under "Preference >> Browse Package"
  • erdembayar
    erdembayar almost 8 years
    Here is little bit correction. PackageResourceViewer >> Open Resource >>Color Scheme >> Monokai (This is my case) In my case "Extract Package" show neither "Theme" nor "Color Scheme". Thanks for your help.
  • Damien
    Damien over 7 years
    I would also add findHighlight and findHighlightForeground
  • Eight-Bit Guru
    Eight-Bit Guru about 7 years
    In my S3 install these keys did not exist in the theme I use, so they had to be added to the same [settings] block as the selection key.
  • Joel Mellon
    Joel Mellon almost 7 years
    Thanks for the notes on editing the theme file with PackageResourceViewer.
  • LarsH
    LarsH about 6 years
    In my case (ST 3.0 build 3143) it was PackageResourceViewer >> Open Resource >> Color Scheme - Default >> Monokai.tmTheme. Thanks, this was helpful.
  • alper
    alper over 4 years
    While changing the backgorund highlight color, is it also possible to change the highlighted text's color such as into black? @Tony Vincent
  • Pynchia
    Pynchia about 4 years
    Where? None of the answers give a clear picture on how to access the mentioned settings
  • geoidesic
    geoidesic about 4 years
    I don't know. Can't recall. I've moved on from Sublime because it was becoming difficult. VsCode does a better job all around.
  • Pynchia
    Pynchia about 4 years
    Yes of course. Changing the selection colour would be nice though
  • Szabolcs Páll
    Szabolcs Páll almost 4 years
    Mac: ~/Library/Application Support/Sublime Text 3/Packages/User/Monokai.sublime-color-scheme Windows: C:\Users\<user>\AppData\Roaming\Sublime Text 3\Packages\User\Monokai.sublime-color-scheme forum.sublimetext.com/t/…
  • Tim John
    Tim John over 3 years
    @alper Yes. See the answer by user2616155