Sublime Forum

Scheme colours for line numbers and tab characters?

#1

I’m making a variation on the Twilight scheme and I’m trying to figure out how to alter the colour and/or transparency of the indenting tabs/spaces and the line numbers. I can see that they are tied to the general text colour…

foreground
#FFF

and that they are a level of transparency based on that. Is it possible to colour them independently and/or change their transparency? If so, what is the key for them?

Thanks.

1 Like

Minor suggestion: background alpha support
Style Comments and Indentations (Python)
#2

OK, after much searching I found you can change the line numbers with…

gutterForeground

Now, if I could just figure out how to change the indenting characters.

0 Likes

#3

Good job on posting an update Fatbat.

I’ve been here for a few months and I haven’t seen anyway to change transparency of indentations through settings.
I can suggest checking the Theme - Default folder it might be in there somewhere.

0 Likes

#4

I found lots of references to “whitespace” while searching but adding…

whitespace
#FF0000 << or whatever colour you like

doesn’t have any effect :frowning:

0 Likes

#5

Option 1: The only way to highlight white space with your color scheme to a particular color is to go through everyone of your syntax languages and scope all white space with a particular scope and then use that scope in your color scheme and highlight the foreground and/or background to your preferences…not very practical.

Option 2: Write a plugin that will automatically highlight all of your white space. Or use an existing plugin that can facilitate your desires.

0 Likes

Change the color of the horizontal tab line?
#6

I’ve seen some schemes with

<key>invisibles</key>

but it doesn’t seem to have any effect.

You should be able to create scopes that change the color for whitespace characters. Unfortunately you’ll have to do so for each language definition:
Plain text.tmLanguage

<dict>
	<key>match</key>
	<string>^\t+</string>
	<key>name</key>
	<string>meta.tab</string>
</dict>

Your scheme.tmTheme

<dict>
	<key>scope</key>
	<string>meta.tab</string>
	<key>settings</key>
	<dict>
		<key>foreground</key>
		<string>#FF0000</string>
	</dict>
		
</dict>

Looks like faceless had the same idea. I agree that it isn’t the best way, but it’ll work!

0 Likes

#7

Hmmm, that looks like a bit of work. I too see the “invisibles” key in my scheme, but it doesn’t seem to do anything at all. Maybe something that will get sorted in a future update.

0 Likes

#8

I figured it out! If you simply add a transparency to your foreground key all the indentation dims but the main text doesn’t. edit: seems to only affect tabs in the whitespace, not spaces.

So in my case I have…

<key>foreground</key>
<string>#E8E0CE40</string>

and voilà! Indentation is perfect :smile:

http://resdivina.com/img/sublime-test.png

0 Likes

#9

Thanks for sharing this Fatbat!

0 Likes

#10

That’s awesome Fatbat! Thanks for sharing this. :smile:

0 Likes

#11

Hey guys I took the advice given here and split up the whitespace sections a bit: github.com/ckovey/sublime-whitespace-coloring

Changing the regex lets me hide whitespace before the code (I like the sublime bars mostly) and make your trailing whitespace red or some color. In my test screenshot I made the first whitespace blue, in-between text whitespace green, and trailing red. Should work for tabs and spaces

<dict> <key>match</key> <string>^\s\t]+</string> <key>name</key> <string>meta.whitespace.leading</string> </dict> <dict> <key>match</key> <string>\s\t]+$</string> <key>name</key> <string>meta.whitespace.trailing</string> </dict> <dict> <key>match</key> <string>\s\t]+</string> <key>name</key> <string>meta.whitespace</string> </dict>

<dict> <key>scope</key> <string>meta.whitespace.leading</string> <key>settings</key> <dict> <key>foreground</key> <string>#75715E00</string> </dict> </dict> <dict> <key>scope</key> <string>meta.whitespace.trailing</string> <key>settings</key> <dict> <key>foreground</key> <string>#FF0000</string> </dict> </dict> <dict> <key>scope</key> <string>meta.whitespace</string> <key>settings</key> <dict> <key>foreground</key> <string>#75715E75</string> </dict> </dict>

There’s something in the ruby lang file that makes the whitespace after do red, but I haven’t looked into that. I mostly wanted to hide leading whitespace and color trailing whitespace

0 Likes

White_space "dots" Too Opaque Since Update to Build 3170
#12

^^^ That’s pretty cool! I just nuke trailing whitespace on save, so I have no real need to colour it differently, but this is still impressive nonetheless.

0 Likes

#13

That is very useful, thank you.

However, do you know how I can fix the issue where it doesn’t always work, especially inside brackets.

For example, if I have (PHP):

if($x) { $code; }
The tab there will be coloured the colour of something else, in this case source.php.embedded.block.html I think.

The whitespace matching code does not match whitespaces in this instance. How do I alter it so that it does?

0 Likes