Sublime Forum

Setting a different highlight in ST3

#1

Hi, I’m new to coding and just got on board with ST3 and its package system.

Basically, I really like a colour scheme with Python or JS but totally dislike its colouring with PHP.
Could it be that there’s an easy way or at least a safe one to swap the colour highlighting of PHP to one used in another language?
If not I’m just going to swap some files and see how messy it gets. :neutral_face:

The theme is Tomorrow Night for those who are curious

0 Likes

#2

If you edit the theme, you will see that there are some generic scopes:

<dict>
	<key>name</key>
	<string>Control Structures</string>
	<key>scope</key>
	<string>keyword.control</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#64d9ee</string>
	</dict>
</dict>

(used for, let’s say if statements; notice scope key: keyword.control)

You can then add another block, only for php:

<dict>
	<key>name</key>
	<string>Control Structures</string>
	<key>scope</key>
	<string>keyword.control.php</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#00FF00</string>
		<key>background</key>
		<string>#CC0000</string>
	</dict>
</dict>

(notice the .php in the scope key)

What you have to do is to add some custom scopes. The shortcut you will need is ctrl+alt+shift+p and you will see in the statusbar current scope.

Make sense?

0 Likes

#3

@iamntz I think he’s asking whether he can set the colour scheme per-language.

@OP… If so, the answer is yes. With a PHP file open (or PHP syntax set for the current buffer) go to Preferences -> Settings - More -> Syntax Specific - User. You’ll likely get a new preferences file. Add the following:

{ "color_scheme": "Packages/Color Scheme - Default/<colour scheme name>.tmTheme" }

Save and close. Incidentally, almost any settings can be made per-syntax/language this way.

Are you using the older “tomorrow night” or the newer “base16-tomorrow dark” theme by the way?

0 Likes

#4

the old one, why?

0 Likes

#5

[quote=“iamntz”]If you edit the theme, you will see that there are some generic scopes:

<dict>
	<key>name</key>
	<string>Control Structures</string>
	<key>scope</key>
	<string>keyword.control</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#64d9ee</string>
	</dict>
</dict>

(used for, let’s say if statements; notice scope key: keyword.control)

You can then add another block, only for php:

<dict>
	<key>name</key>
	<string>Control Structures</string>
	<key>scope</key>
	<string>keyword.control.php</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#00FF00</string>
		<key>background</key>
		<string>#CC0000</string>
	</dict>
</dict>

(notice the .php in the scope key)

What you have to do is to add some custom scopes. The shortcut you will need is ctrl+alt+shift+p and you will see in the statusbar current scope.

Make sense?[/quote]

Thanks it worked at last. I had to use scopehunter to find out that the correct scope is variable.other.php not just variable.php

0 Likes