Sublime Text 3 - whitespace color wrong after update - colors

So I've updated Sublime Text 3 to version 3170 on Ubuntu today and apparently this broke my whitespace coloring - I always have this option set:
draw_white_space": "all"
because I like seeing my spaces and tabs in dark grey - not distracting, but visible enough to be able to see/count them or locate tabs that should be spaces instead.
After the update, the whitespaces are light green, which makes them super distracting. Is there any way to set this back to grey?

One of the features of Stable build 3170 (and many of the Dev builds in this series) is support for invisibles in the tmTheme color scheme as well as in the new sublime-color-scheme format. This is something that existed in tmTheme prior to this, but Sublime did not use the value in that color scheme key and instead used another color.
At the moment it's unclear exactly what color was originally used, but possibly it was the foreground color with an alpha value applied to "dim" it, so the following may require some experimentation to find the right color.
A side effect of this change is that for some color schemes, the color scheme author may have had a value in the invisibles key that was not honoured previously but which now is, which makes things display incorrectly. Or correctly, depending on how you look at it.
You mentioned in comments above that you're using Neon Color Scheme and in that scheme the invisibles value is set to #06FF05 which is indeed a green color.
In order to solve your problem you need to edit the color scheme to apply a different color to that part of the color scheme to get the gray color that you want.
The easiest way to accomplish this would be to take advantage of the addition of the sublime-color-scheme resource type in Sublime Text. Many resource types in Sublime "stack" together at load time to allow for the creation of a partial override.
It turns out that in the case of this particular file format, sublime-color-scheme stacks with tmTheme files of the same base name, since they are represented the same way in memory once they're loaded.
As a result of that, you can adjust the invisibles color by creating a file with the name Neon.sublime-color-scheme in your User package with the following contents:
{
"globals":
{
"invisibles": "#FF00FF"
}
}
The Neon.sublime-color-scheme stacks with the Neon.tmTheme from the package, and since the User package content is always loaded last, this overrides just the invisibles color (in this case to magenta) but leaves the rest of the color scheme untouched.
This of course applies to any color scheme so long as you know the name of the tmTheme file that you're using. The same mechanism can be used to extend your theme to include colors for new scopes or alter the colors of existing scopes without having to recreate a whole new tmTheme or sublime-color-scheme file. See the color scheme documentation for more information.
Doing this creates a partial override, which means that regardless of the content of the underlying color scheme, your changes will still take effect with no overt warning. In this case that's pretty low key as far as potential problems are concerned.
Another way to accomplish this goal is to make changes to the tmTheme file by creating an override. This is marginally more complicated than the above but potentially still useful. For example, this can be used for any package resource of any type in order to modify things to your liking.
In order to create such an override:
Install PackageResourceViewer if you don't already have it installed.
Enter prvo in the command palette and select PackageResourceViewer: Open Resource
Select Neon Color Scheme, then Neon.tmTheme (or the appropriate package and file, depending on what you're doing)
Make appropriate changes to the file as desired and save
This sequence of steps opens the underlying package resource file for you to look at and/or modify. Saving the file creates an override by creating a folder in the Packages folder named for the package and putting the modified file inside. When Sublime loads package resources, the version that's unpacked in the Packages folder takes precedence over the version that's in the package.
In the case of a color scheme tmTheme file, near the top you'll see a settings key, and inside of it, this set of tags sets the color used for invisibles, which you can modify as you see fit.
<key>invisibles</key>
<string>#06FF05</string>
As with any override, once you do this your version of the color scheme (or any other package reaource) will supersede the version that ships with the package, which means that if the package gets updated, your version of the file will still be used without any warnings or messages to tell you that it's happening.
That's probably not a big deal for a color scheme; the OverrideAudit package will warn you if this happens if you're worried. Alternatively, you can make the modifications as above but do a Save As instead of a Save and save the file in your User package, and then alter the color scheme setting to use that version of the color scheme instead.
If you do that and use the same file name, the scheme will appear twice in the color scheme selector; make sure you choose the version that says it's in the User package to be sure you're using your modified version.

Customize your color scheme's whitespace setting:
Sublime Text > Preferences > Customize Color Scheme
{
"globals": {
"invisibles": rgba(255, 255, 255, 0.15)
}
}
No plugins necessary (:
Sublime Theme Customizing Docs here

Related

How to show whitespace for given scope in a Sublime Text color scheme

Is there any way to set white space visible for a given scope?
I'm working on modifying a color scheme to suite my liking and would like to be able to show spaces within a given scope. I haven't seen anything suggesting it's possible within the color-scheme documentation on Sublime's website.
For my specific case, and I imagine there's other useful cases, I'm working with Markdown and want to highlight a double-space line-break. I'm able to set the background, but this doesn't look quite right. I'm hoping to be able to make whitespace visible for this small scope and change the foreground color to make it stick out.
The short answer to your question is no; or rather, Yes, but only in the way that you've already discovered.
Color schemes can only apply foreground/background colors to scopes as well as bold/italic font weights. So assuming that there is a specific scope detected by the syntax you're using that is used for the things you're trying to highlight, the only thing the color scheme can do is alter the background color to make them visible.
The only thing that can render white space natively is the draw_white_space setting, which at the moment only allows you to turn it off everywhere, turn it on everywhere, or turn it on only for selected text. In this case that doesn't really help.
There are possibilities for something like this in the plugin realm though (these examples can be tested by opening the Sublime console with View > Show Console or Ctrl+` and entering the code in there; they also assume that you're using the default Markdown syntax):
view.add_regions("whitespace", view.find_by_selector("punctuation.definition.hard-line-break.markdown"), "comment", flags=sublime.DRAW_NO_FILL)
This will cause all of the hard line breaks to be outlined as if they were find results; the color is selected by the scope (which is comment here); that would make them visible without making the whole character position have a background color.
view.add_regions("whitespace", view.find_by_selector("punctuation.definition.hard-line-break.markdown"), "comment", "dot", flags=sublime.HIDDEN)
This will add a dot (colored as a comment) in the gutter for lines that end with this scope; you can also combine this with the previous example to outline them and also call attention in the gutter.
style = '<style>.w { color: darkgray; }</style>'
content = '<body id="whitespace">' + style + '<span class="w">ยทยท</span></body>'
phantom_set = sublime.PhantomSet(view, "whitespace")
phantoms = [sublime.Phantom(r, content, sublime.LAYOUT_INLINE) for r in view.find_by_selector("punctuation.definition.hard-line-break.markdown")]
phantom_set.update(phantoms)
This uses Sublime's ability to apply inline HTML phantoms into the document in order to inject a small inline sequence of two unicode center dots immediately between the actual whitespace and the text that comes before it. Here the content can be what you like if you can generate the appropriate HTML; we're just applying a color to the text in this example.
A potential downside here is that the characters you see in the inline HTML aren't considered to be part of the document flow; the cursor will skip over them in one chunk, and they're followed by the actual whitespace.
The result of this example looks like this:
Going the plugin route, you'd need an event handler like on_load() to apply these when a file is loaded and on_modified() to re-update them after modifications are made to the buffer. There may or may not be a package that already exists that has implemented this.

How to change color of font?

How to change color of certain type label of syntax?
I know that there is file of color scheme but what line of that file is related to colors of certain label (e.g. class or function).
For example, there is a piece of code in Sublime Text 3:
I do not want to see label 'Node' (that is class-label) yellow but want to see it blue. How I can do it?
To do this you need to make a modification to the color scheme that you're using to tell it to color things in a different format. In particular, you need to know two things:
The color scheme that you're currently using.
The scope of the thing whose color you want to change.
To determine your color scheme, look in your preferences for the value of the color_scheme setting. Here I'm going to assume that it looks like this:
"color_scheme": "Mariana.sublime-color-scheme",
Depending on how you set up the color scheme this might have part of a path as well, like Packages/Color Scheme - Default/Mariana.sublime-color-scheme instead. The file may also have a tmTheme extension instead of sublime-color-scheme if you're using a legacy color scheme.
To determine the scope you need to change, put the cursor on the thing whose color you want to change and use Tools > Developer > Show Scope Name (or press the key that menu tells you about), then make a note of what the last line of the popup says. In this case, we're assuming it is:
entity.name.class.c++
Your color scheme has a rule in it that tells it that things with a scope that matches this should appear the color that they do, so you need to adjust that color to be what you want.
To do that, you create a file in your User package, which you can locate by using Preferences > Browse Packages.... The file that you create should be the name of the color scheme you're using (just the filename, not the path if any) with an extension of sublime-color-scheme (even if the extension on your color scheme is tmTheme.
In our example, that means that we would create a file named Mariana.sublime-color-scheme in the User package.
The content of your file should look something like this:
{
// http://www.sublimetext.com/docs/3/color_schemes.html
"rules": [
{
"scope": "entity.name.class",
"foreground": "var(blue)",
},
]
}
This tells Sublime that for anything whose scope matches entity.name.class, it should use the color outlined by the variable blue instead of what your normal color scheme is doing. As soon as you save the file, you see the results appear.
We use entity.name.class here instead of entity.name.class.c++ to make the scope match anything that's considered a class in any file. Basically the more of the scope from #2 above that you use, the closer the match will be. So if you use it all, it only affects C++.
The last thing to note here is that var(blue) will only work if your color scheme defines a variable named blue. The Mariana color scheme does, which is why I used that here. Yours may not, in which case you need to specify the color a different way.
The link in the example above points to the color scheme documentation with more details, but you could use something like #0000FF in place of var(blue) to get pure blue (adjust as required, that blue is likely far too dark).

How to change color of new Diff Markers in Sublime Text 3?

I want to change the Diff Marker colors that appear just to the right of the number column in sublime text 3 editors.
https://www.sublimetext.com/docs/3/incremental_diff.html
I tried going to preference -> Settings but cannot find any property line_diff_added or line_diff_modifies.
How should I update these colors?
The colors for the mini_diff indicators are specified by the color scheme that you're using; the line_diff_added and other items you mention are contained in that file.
To modify them you can create a customization on whatever color scheme you're currently using by creating a sublime-color-scheme file in your User package that is named after your color scheme, which contains the customized colors.
To determine your color scheme, check the color_scheme setting in your preferences; you can also determine where your User package is by using Preferences > Browse Packages if you're unsure.
When you create such a file in your User package, Sublime will load the base file first and then apply your changes on top; hence you can adjust just the parts of the color scheme that you want while retaining all of the defaults.
As an example, if you use the Monokai color scheme that ships with Sublime, then creating a file named Monokai.sublime-color-scheme in your User package with the following contents:
{
"globals":
{
"line_diff_added": "var(yellow2)",
"line_diff_modified": "var(blue)",
"line_diff_deleted": "var(red)",
"line_diff_width": "5"
},
}
Will create diff markers similar to this:
In this particular example, the colors being referenced are specified as variables in the base Monokai.sublime-color-scheme file; you're free to choose whatever colors you like for this, of course. You can use View Package File from the command palette to peek at the color scheme you're using if you want to see what it's doing on its own.
Note also that if you happen to be using a legacy color scheme of type tmTheme, the above still applies; if you were using SomeLegacyTheme.tmTheme, then you would create SomeLegacyTheme.sublime-color-scheme in your User package to customize it (note that the extension is different).
See the docs on Color Schemes (and in particular on customizing them) for more detailed information on this, including how you can specify the colors you want to use.
Try adding new key to *.tmTheme file.
To see which *.tmTheme file exactly is used in your case:
preferences - color_scheme key
Just like this in your *.tmTheme file.
<key>settings</key>
<dict>
<key>line_diff_width</key>
<string>8</string>
[...]
</dict>

How can I detect (and change) whether the font used in Charts in Excel and PowerPoint will follow the style or have been specified by a user?

When a chart is copied from Excel to PowerPoint, if the fonts on the Axis have been changed due to the style or theme applied in Excel, then they will normally change to be consistent with whichever theme is applied in PowerPoint (which is good). However, when the font (possibly formatting in general) has been overridden by a user, that the user specified font is the one used.
Writing code to detect what the default font is and apply it probably isn't that tricky, but I'd rather apply the theme font in a way that will match subsequent theme changes. Can anyone tell me how to do this?
I'm using C#, but am familiar with VBA and the object model is more or less identical in both, so approaches in either language should be fine.
After a little more digging, setting any font to a theme font looks like it can be accomplished by using the special font names comprised of:
+mj or +mn for heading or body fonts respectively
-lt, -ea, or -cs for latin, east asian, or complex script fonts respectively
So for my purposes, if I just assign all heading-like shapes' font properties to have font.name = "+mn-lt" then I accomplish what I need to, i.e. the font will match the theme and reflect subsequent theme changes.
NB that detecting whether this actually is already the case, since the font can be assigned either using the special font name or the actual font name, is a difficult problem (addressed elsewhere on SO). Thankfully, I don't have to worry too much about this...

Orange Dot for Sublimetext3 dirty files

Modifying Preferences/Settings - User and adding: "highlight_modified_tabs":true, gets me highlighted TEXT in the tab for dirty files, but I cannot get the greyed out dot on the tab to change colors as well.
What I'm trying to accomplish is to have the dirty file dot change to orange like the text on the tab does by modifying the above settings, except I want only the dot to change color and not the text on the tab.
Answering my own question for those who may run into this issue.
After a lot of fiddling around, I figured out that within the Default.sublime-theme file on the lines describing the close file button which start at line 729 (for me at least) you will see a bunch of different code blocks that look like this:
{
"class": "tab_close_button",
"parents": [{"class": "tab_control", "attributes": ["dirty", "file_medium_dark"]}],
"layer0.opacity": 0.0,
"layer1.opacity": 0.0,
"layer2.opacity": 0.0,
"layer3.texture": "Theme - Default/dirty_circle_light.png",
"layer3.opacity": 0.5
},
There are several different blocks like the above that correspond to the tab_close_button class for the dirty attribute, presumably related to the background color of your theme. For me, running Tomorrow Night Eighties - I had to modify the above block which contained the reference code for whatever "file_medium_dark" may be (I just assumed medium_dark would catch my theme since it's, well ... medium dark).
You can apparently also change the dirty_circle or dirty_indicator png files directly, but I couldn't find good replacements on the web and when I tried to modify some directly in paint the results were weird - I would get a nice bright grey box housing the circle with the color I wanted instead of just the circle.
The change:
simply add into the above block "layer3.tint":[255,161,52] or whatever RBG color you want. Also, change the opacity from 0.5 to 1.0 or it will be very muted. One unintended consequence is that when you hover over the dirty file dot the 'x' will now be colored a translucent version of whatever color you set the dirty dot to, as opposed to the default light colored x. I'm sure there is a way to fix this that has to do with the dirty_x attributes but I'm tired of messing with it.
Also, not sure if this is relevant but some others on SO and various forums mentioned that making the change directly in the Default.sublime-theme file can have unintended consequences, and they advocated making a copy of this file within the packages/user folder and making the changes there, since apparently this file is loaded independently and applied after and on top of the default changes.

Resources