Inside F#

Brian's thoughts on F# and .NET

Archive for June, 2012

F# Depth Colorizer for VS2012 now available

Posted by Brian on June 24, 2012

The F# Depth Colorizer for VS2012 makes it easy to see the nesting-depth of your F# code and ensure that control constructs are properly indented.  Compare:


The left screenshot shows how code appears by default.  Are the ‘try’ and ‘with’ keyword aligned?  It can be hard to tell at-a-glance.  The right screenshot has the F# Depth Colorizer installed; small changes in background color at each level of nesting/indent highlight various code blocks and make it easy to see where the indents are.

This extension to Visual Studio 2012 parses F# code as you type and interactively updates the background colorization to match the actual parsed structure of the code.  It understands the full F# 3.0 language syntax.

This extension is a free VSIX on the Visual Studio Gallery, so it is easy to download and try out.  Once installed, it will appear on the Visual Studio 2012 ‘Tools\Extensions and Updates…’ menu:


where you can easily remove it if you decide it’s not for you.

Are you using the new ‘dark’ theme colors in VS2012?  Not a problem, the extension can detect dark default colors, and switches to a more appropriate color set for highlighting in the dark theme:


Like the extension, but don’t like the default colors?  You can change them.  UI is not my strong point, so unfortunately the colors are only configurable via the registry (rather than some pretty color-editor GUI).  Here is the registry entry for the default light-theme colors:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor\FSharpDepthColorizer\Light]

and dark-theme colors:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor\FSharpDepthColorizer\Dark]

(You can save these registry examples to a file “foo.reg”, run the “foo.reg” file to install those keys, and then use the “regedit” tool to inspect/change the values. Be careful when modifying your registry!)

The DepthN values are strings of six numbers, representing two sets of RGB values, e.g.

DepthN = R1, G1, B1, R2, G2, B2

where N is the depth of the nesting of the source code structure, the RGB1 values are the color of the left edge of the highlight (intention is to provide more visual contrast at the edge), and the RGB2 values are the main color for highlighting that nesting depth.

Note that this is a new extension specifically designed for VS2012 (currently at the RC ‘Release Candidate’ stage); if you are using VS2010, then you’ll need to use the older version of this tool instead, linked here.

Posted in Uncategorized | Leave a Comment »