This question is a follow up from Formatting notebook files
In Programmatic formatting for Mathematica code - possible? masterxilo proposed to use <<GeneralUtilities` then GeneralUtilities`PrintDefinitions@f whereby f is some mathematica code to get a pretty-printed, formatted version of ??f.
Leonid Shifrin wrote a very nice software which is aimed to format mathematica code: https://github.com/lshifr/CodeFormatter
Concerning GeneralUtilities Leonid Shifrin wrote to masterxilo:
"I have to admit that the formatter implemented in GeneralUtilities impressed me a lot ...".
I used Leonid Shifrins code as well tried to use GeneralUtilities as masterxilo proposed with the following one-liner:
Do[x = i; Do[y = j; Do[z = k;, {k, 1, 3}];, {j, 1, 3}];, {i, 1, 3}]
Leonid Shifrins code gives nearly what I expect:
Import["https://raw.githubusercontent.com/lshifr/CodeFormatter/master/\
CodeFormatter.m"]
Needs["CodeFormatter`"]
prn = CellPrint[Cell[BoxData[#], "Input"]] &; prn@
FullCodeFormat@
CodeFormatterMakeBoxes@
Do[x = i; Do[y = j; Do[z = k;, {k, 1, 3}];, {j, 1, 3}];, {i, 1, 3}]
Why does the Null appears?
masterxilos proposal opens up a new notebook with the information: Attributes[Null] := {Protected};:
<< GeneralUtilities`
GeneralUtilities`PrintDefinitions@
Do[x = i; Do[y = j; Do[z = k;, {k, 1, 3}];, {j, 1, 3}];, {i, 1, 3}]
What do I wrong?


f[] := Do[x = i; Do[y = j; Do[z = k;, {k, 1, 3}];, {j, 1, 3}];, {i, 1, 3}]withPrintDefinitionsLocal[f]. – Karsten7 Sep 27 '16 at 11:19PrintDefinitionsLocal. – mrz Sep 27 '16 at 13:57PrintDefinitionsLocal@PrintDefinitionsLocal, there are no options settings to do adjustments. However, you can inspect it a little deeper and figure out that, e.g.,Block[{GeneralUtilities`Debugging`PackagePrivate`$PrintDefinitionsBackground = Orange}, PrintDefinitionsLocal[f]]will produce an orange background for the printed cells. – Karsten7 Sep 27 '16 at 14:14?GeneralUtilities``*I do not seeDebugging` listed. How did you find it? – mrz Sep 27 '16 at 14:39PrintDefinitions. – Karsten7 Sep 27 '16 at 14:45?GeneralUtilities`*`*also reveals that parameter. – Karsten7 Sep 27 '16 at 15:27