I'm trying to syntax highlight this expression: x=$\sqrt{\pi }$//N and from various sources I've learned that x (the assigned symbol) belongs to context Global while the Pi and N belongs to System. So I set out to change the style of both using a hodgepodge of tips I gleaned from this StackExchange as well as from StackOverflow.
However, the weird thing is that the style changes do not add to each other. If I change the style of System, any previous style change to Global would be wiped away, and vice versa. In other words, I can have syntax highlighting for either System, or Global, but not both. This could be seen from these screenshots (sorry for the small font, code added):
First line:
SetOptions[$FrontEndSession,
"AutoStyleOptions" -> {"SymbolContextStyles" -> {"System`" ->
RGBColor[211./255, 54./255, 130./255]}}] (*magenta*)
Setting System style: magenta
Second line:
SetOptions[$FrontEndSession,
"AutoStyleOptions" -> {"SymbolContextStyles" -> {"Global`" ->
RGBColor[181./255, 137./255, 0./255]}}] (*yellow*)
Setting Global style: yellow; when evaluated, previously set System style was wiped out
Could anyone guide me toward getting syntax highlighting for both of them? I really hope MMA has better syntax highlighting on their future releases.
"Input"
style by editing the stylesheet. Enter/choose the Input style, select the cell, use menu command Edit > Show Expression, and add the option so that the cell expression looks like this:Cell[StyleData["Input"], AutoStyleOptions->{"SymbolContextStyles"->{"System`" -> RGBColor[211./255, 54./255, 130./255], "Global`" -> RGBColor[181./255, 137./255, 0./255], Automatic -> {}}}]
. Then the style will persist from session to session. $\endgroup$