I've been playing around a lot with making a new style sheet with corresponding syntax colorings in the past few days, but I'm finding the default options pretty lacking. While you can use the preferences menu to set comment colors, string colors, undefined symbol colors, and local variable colors, there is no way to differentiate between, say, variables and functions, which is what I'm ultimately looking for in a color scheme. At the heart of the matter, I essentially want to be able to set syntax specific coloring for a defined term (whether it be Plot
or a variable) based on the Head of that term.
As a concrete example, let's say I define a = {1,2,3}
and b = 2
. Is there any way to have the variable a
be colored red (as it is a List head) wherever it appears, the variable b
be colored blue (as it is an Integer head) wherever it appears, and the function Plot
be colored green (as it is a Symbol head) wherever it appears.
Edit: After more digging I've found this answer: https://stackoverflow.com/questions/6130514/syntax-coloring-in-mathematica, which gets quite close to what I'm looking for - I guess the natural follow-up is if it is possible to set an object's context programmatically by it's Head (and here my lack of deep Mathematica knowledge is probably showing - this might not even be a sensical question).
red`a
is just a different symbol thanblue`a
and it will only lead to troubles. $\endgroup$AutoStyleOptions
but it’s pretty much impossible to do classes ofSymbols
unless you do some expensive work withDynamic
that’ll blow up in usage complexity and be very fragile. $\endgroup$