Sublime Forum

Code colouring question

#1

Hi there, I’ve been playing with the code colouring recently but I can’t seem to find a way to change the colour or the angle brackets in HTML. Ideally I would like to make them the same colour as the rest of the tag (not unlike the blue PHP tags).

I wonder if anyone could help?

0 Likes

#2

This depends a bit on the colourscheme you are using and how it defines colours for scopes. So in my colourscheme (Base16-Tomorrow-Dark.tmTheme), I find the scope entity.name.tag (the colour for the tag text ie. red) and add to it punctuation.definition.tag (the colour for ‘tag punctuation’ which is the angle brackets and slashes). Code:

Before:

<dict>
	<key>name</key>
	<string>Tags</string>
	<key>scope</key>
	<string>entity.name.tag</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#cc6666</string>
	</dict>
</dict>

After:

<dict>
	<key>name</key>
	<string>Tags</string>
	<key>scope</key>
	<string>entity.name.tag, punctuation.definition.tag</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#cc6666</string>
	</dict>
</dict>

This will work for all languages which have tags (HTML, XML etc). Explanation: scopes themselves are defined in language rule files (XML .tmLanguage or the new YAML .sublime-syntax), and colourscheme .tmTheme files apply colours to the scopes. All we’ve done here is set the ‘tag punctuation’ scope to have the same colour as the tag itself. You see the scope tree for text under the caret by pressing ctrl+alt+shift+p.

:slightly_smiling:

3 Likes