44

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.

Henrik
  • 2,771
  • 1
  • 23
  • 33
erdembayar
  • 603
  • 1
  • 6
  • 12

3 Answers3

52

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

Deepak
  • 3,134
  • 2
  • 24
  • 24
Tony Vincent
  • 13,354
  • 7
  • 49
  • 68
  • 4
    Where is that theme file? Above was true for Sublime 2. But I don't see theme files under "Preference >> Browse Package" – erdembayar Sep 01 '16 at 04:45
  • 18
    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. – erdembayar Sep 01 '16 at 06:30
  • Thanks for the notes on editing the theme file with PackageResourceViewer. – Joel Mellon Sep 14 '17 at 21:36
  • 2
    In my case (ST 3.0 build 3143) it was `PackageResourceViewer >> Open Resource >> Color Scheme - Default >> Monokai.tmTheme`. Thanks, this was helpful. – LarsH Apr 10 '18 at 20:35
  • While changing the backgorund highlight color, is it also possible to change the highlighted text's color such as into black? @Tony Vincent – alper Feb 26 '20 at 09:08
  • @alper Yes. See the answer by user2616155 – Tim John Feb 12 '21 at 08:11
17

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>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
user2616155
  • 330
  • 2
  • 9
6

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"
    },
}
Dee
  • 7,455
  • 6
  • 36
  • 70
geoidesic
  • 4,649
  • 3
  • 39
  • 59
  • 2
    Where? None of the answers give a clear picture on how to access the mentioned settings – Pynchia Jun 19 '20 at 12:31
  • 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. – geoidesic Jun 20 '20 at 13:20
  • Yes of course. Changing the selection colour would be nice though – Pynchia Jun 20 '20 at 14:51
  • Mac: ~/Library/Application Support/Sublime Text 3/Packages/User/Monokai.sublime-color-scheme Windows: C:\Users\\AppData\Roaming\Sublime Text 3\Packages\User\Monokai.sublime-color-scheme https://forum.sublimetext.com/t/how-to-change-highlight-backgroud-foreground-on-mac/37178 – Szabolcs Páll Aug 06 '20 at 07:58