Sublime Forum

Monokai Color customization

#1

Apart from what is mentioned here can I change the red color in monokai theme to Royal blue

Looking for alternative method rather than creating that file.

0 Likes

#2

That file is like ten lines. That’s what you ought to be doing.

0 Likes

#3

In addition, there is no alternative; color schemes provide color rules and are the only way to change what’s being displayed:

{
    "rules":
    [
        {
            "name": "Tag name",
            "scope": "entity.name.tag",
            "foreground": "royalblue"
        },
    ]
}
0 Likes

#4

From where can I get the complete copy of that file/theme that I can modify

0 Likes

#5

The file I was talking about has been made for you by @OdatNurd above.

If you mean the full Monokai theme, you’ll have to extract it from the “Default” package. Odat has a package named OverrideAudit that will do that, or (because it’s specifically a color scheme), you can use PackageDev’s “Edit Current Color Scheme”.

There might be a built-in ST command to browse packaged resources, but I don’t know it if there is one. Odat would know.

0 Likes

#6

View Package File from the command palette will let you look at package resources, if you’re interested in seeing what the full color scheme looks like. However I would also second the recommendation for using PackageDev if you want to do anything other than what I provided above.

0 Likes

#7

Ok. Howto right hex color sir: #485aaa?

Also sir, I have done a counter with what name will they be called?

when compared to these two variables:

"name": "Tag name",
      "scope": "entity.name.tag",
0 Likes

#8

I think this is the clue:

0 Likes

#9

Hi there,

1,2,3 and 4 are controlled by which tags? Please help me → especially 2nd one. Thanks.

0 Likes

#10

While your cursor is inside of the word or thing you want to style, go to the menu and choose Tools > Developer > Show Scope Name, or press the associated key binding for it, which you can see in the menu.

That will make a popup appear that shows you the full, complete scope that is applied to the text under the cursor that’s responsible for making it the color that it is,

For your #2 example, that might look something like this:

image

Each line here is one scope term which, when all combined together, indicates the exact structure of the thing under the cursor. The more of this you use in your rule the more specific you can make your color rule.

Generally speaking, you usually want to focus on the last thing shown unless you’re trying to be super specific about things. For example, you could use variable.function.js to ensure that your color rule only applies to functions in JavaScript, variable.function to make it apply to every function in every language, or just variable to have it apply to all variables.

If you’re tweaking an existing color scheme, you can check in the existing scheme and search for rules using these terms to see what the color scheme is doing. You can then copy that rule over to your file and modify the color, or use the color rule as a basis for your own.

You may be interested in these videos, which talk about Scopes in detail and also walk you through how color schemes work and how to customize them or make your own from scratch.

2 Likes

#11

Thanks.
The scope is clear now how to find a name(say for source.js.embedded.html ), this for example:

{
	"name": "Library function",
	"scope": "support.function",
	"foreground": "brown"
},

has the name Library Function

I tried this, and it created a disaster:

{
"name": "new Sfunction",
"scope": "source.js ",
"foreground": "brown"
},
0 Likes

#12

The scopes for all things can be found the same way.

A little playing around with the key binding mentioned above will show you that source.js applies to everything that’s JavaScript, so making that brown is going to ensure that anything JavaScript related that doesn’t have a specific color applied to it is going to be brown, which is probably not what you want.

Unless you have some compelling reason to syntax highlight JavaScript differently in .js files as opposed to when it’s embedded in an .html file, I would ignore any nuance related to source.js or anything that mentioned embedded html and just focus on the most specific scope rule (which in your case is support.function).

0 Likes

#13

There might be a built-in ST command to browse packaged resources, but I don’t know it if there is one. Odat would know.

It’s called Package Resource Viewer: Open Resource, from the Command Palette, FWIW.

0 Likes

#14

The built in command is View Package File; Package Resource Viewer is an add-on package you need to install.

All else being equal, if you’re going to open a file for editing in this manner, I would recommend OverrideAudit over PackageResourceViewer; it has a similar command and is safer in that it doesn’t also have commands that allow you to accidentally override every resource at once without realizing it. Also it helps you manage your changes.

Of course, I’m biased. :wink:

2 Likes

#15

Just out of curiosity I am asking sir - Are you the founder of sublime text software?

0 Likes

#16

No, nobody that’s responded in this thread is associated with Sublime HQ.

2 Likes

#17

Ok sir you are very experiences. do we have such theme in sublime inventory of themes:

I like the color and font combination.

0 Likes

#18

The name key is just a hint to the color scheme developer, it is not used by anything - consider it more like a comment. It can be safely omitted, and in many cases should be, because the scope selector is clear enough on its own.

4 Likes