Wednesday, April 21, 2010

How To Configure AllMargins Extension For Visual Studio 2010

UPDATE: Removed non AllMargins registry settings. Thanks David Pugh for letting me know.


UPDATE 2: Productivity Power Tools now combines most of the major features of AllMargins, due to David Pugh himself porting it over. Consider using it instead.


AllMargins is a VS 2010 extension that basically replaces Rockscroll from VS2005 and VS2008. It combines multiple extensions into one “All” inclusive extension. Here is an example of what mine looks like with a few features pointed out:

image

It looks pretty good now, but when you first install it, it is configured for a white background, rather than black. You can change the colors via the registry at \HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor, but I couldn’t find any documentation online as to what color controls what. I downloaded the code from code.msn.microsoft.com and discovered how it all worked.

AllMargin Extensions

AllMargins contains multiple extensions, but all of their configurable settings are located in the registry at \HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor. I’ve listed them by extension below along with the introduction and usage text I’ve pulled together from the readme files in the projects. Just edit the appropriate registry setting and open up a new window in VS2010, to see any changes you’ve made.

CaretMargin

This extension adds a margin to the OverviewMargin that shows the location of the caret and all words that match the word the caret is on.

You will see colored rectangles drawn that correspond to the location of the caret and all words that match the word the caret is in or adjacent to.

Registry Name Description
CaretMargin/MarginEnabled Should the CaretMargin be displayed
CaretMargin/MarginWidth Width of the CaretMargin (in pixels)
CaretMargin/CaretColor Color used to draw the location of the caret. Not used if Alpha = 0
CaretMargin/MatchColor Color used to draw the location of matching words. Not used if Alpha = 0


OverviewMarginImpl

This extension creates a margin displayed along the right edge of the editor. It, like the vertical scroll bar, logically maps to the entire file. By default, it acts as if all elided regions are expanded (though the portions of the file contained in a elided regions are highlighted). The OverviewMargin also can highlights the portions of the file that are above, contained in and below the text shown in the editor.

The OverviewMargin is a container for other margins (that all use a common mapping between a location on the screen and a position in the file). This extension includes two of these contained margins: the OverviewChangeTracking margin (which acts like the change tracking margin from the left side of the editor, but applied to the entire file) and the OverviewMark margin (which allows 3rd parties to draw colored marks to indicate positions of interest in the file).

Moving the mouse into the OverviewMargin will, after a brief delay, show a tooltip. The default tip for the OverviewMargin shows the contents of the file at the corresponding location but other margins contained in the OverviewMargin may provide more interesting tips.

Left clicking in the OverviewMargin to scroll to center the corresponding location in the editor. Left clicking in an elided region will center the(collapsed) elided region in the editor.

Double-left-clicking in the OverviewMargin will expand any elided regions that contain the corresponding location and then center that location in the editor.

Right-clicking in the OverviewMargin brings up an option menu that allow you to change:
Whether or not the OverviewMargin acts as if all elided regions are expanded (if they are not, then the OverviewMargin uses the same mapping between a location in the margin and a position in the file as the vertical scroll bar).
Whether or not the OverviewMargin will show the default tip when the mouse is inside the margin.

Registry Name Description
OverviewMargin/ChangeTrackingMarginEnabled Should the change tracking margin be displayed
OverviewMargin/MarkMarginEnabled Should the mark margin be displayed
OverviewMargin/ExpandElisionsInOverviewMargin Are elisions expended in the overview margin?
OverviewMargin/OverviewMarginPreviewSize Number of lines to show in the default tip for the overview margin. If 0, do not show any tip by default
OverviewMarginImpl/ChangeTrackingMarginWidth Width of the ChangeTrackingMargin (in pixels)
OverviewMarginImpl/MarkMarginWidth Width of the MarkMargin (in pixels)
OverviewMarginImpl/ElisionColor Color used to highlight elided text as ARGB. Not used if Alpha = 0.
OverviewMarginImpl/OffScreenColor Color used to highlight portions of the file not shown in the editor as ARGB. Not used if Alpha = 0.
OverviewMarginImpl/VisibleColor Color used to highlight portions of the file shown in the editor as ARGB. Not used if Alpha = 0.


Structure Adornment

This extension displays vertical lines in the editor to help show the block structure of the code file. Different colors are used to indicate different types of blocks.

Moving the mouse over one of the colored lines will, if the line extends off the top of the editor, create a tooltip at the top of the view that provides some context on what is out of view.

Registry Name Description
StructureAdornment/ClassColor Color used to show the scope of class definitions as ARGB
StructureAdornment/ConditionalColor Color used to show the scope of conditionally executed code as ARGB
StructureAdornment/LoopColor Color used to show the scope of loop bodies as ARGB
StructureAdornment/MethodColor Color used to show the scope of method bodies as ARGB
StructureAdornment/UnknownColor Color used to show the scope of unknown blocks as ARGB
StructureAdornment/Enabled Should the structure adornments be shown?


StructureMargin

This extension adds a margin to the OverviewMargin that shows the block structure of the code file. Different colors are used to indicate different types of blocks.

Moving the mouse over the structure margin will create a tooltip that provides some context on what is in the file at that location.

Registry Name Description
StructureMargin/ClassColor Color used to show the scope of class definitions as ARGB
StructureMargin/ConditionalColor Color used to show the scope of conditionally executed code as ARGB
StructureMargin/LoopColor Color used to show the scope of loop bodies as ARGB
StructureMargin/MethodColor Color used to show the scope of method bodies as ARGB
StructureMargin/UnknownColor Color used to show the scope of unknown blocks as ARGB
StructureMargin/MarginEnabled Should the StructureMargin be displayed
StructureMargin/MarginWidth Width of the StructureMargin (in pixels)
StructureMargin/MethodEllipseColor Color used to draw the ellipse that shows the scope of method bodies as ARGB. Not used if Alpha = 0


My Settings

Here are my setting that I use. If you want to use them, just save them as a .reg file to add/update them in the registry


Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor]
"StructureAdornment/ClassColor"="#FF5F7D7C"
"StructureAdornment/ConditionalColor"="#FF005300"
"StructureAdornment/LoopColor"="#FFFF0000"
"StructureAdornment/MethodColor"="#FF222290"
"StructureAdornment/UnknownColor"="#FF362844"
"StructureAdornment/Enabled"="True"
"OverviewMargin/ExpandElisionsInOverviewMargin"="True"
"OverviewMargin/PreviewSize"="20"
"OverviewMarginImpl/ElisionColor"="#404252FF"
"OverviewMarginImpl/OffScreenColor"="#FF000000"
"OverviewMarginImpl/VisibleColor"="#88444444"
"OverviewMargin/ChangeTrackingMarginEnabled"="True"
"OverviewMarginImpl/ChangeTrackingMarginWidth"="9"
"OverviewMargin/MarkMarginEnabled"="True"
"OverviewMarginImpl/MarkMarginWidth"="8"
"CaretMargin/Enabled"="True"
"CaretMargin/CaretColor"="#AADDFFFF"
"CaretMargin/MatchColor"="#FF6F8474"
"CaretMargin/MarginWidth"="7"
"StructureMargin/MarginEnabled"="True"
"StructureMargin/MarginWidth"="25"
"StructureMargin/MethodEllipseColor"="#20DDDDDD"
"StructureMargin/ClassColor"="#FF38E4DB"
"StructureMargin/ConditionalColor"="#FFAF22C8"
"StructureMargin/LoopColor"="#FF0AC034"
"StructureMargin/MethodColor"="#FFE86D0E"
"StructureMargin/UnknownColor"="#FFE8DE1B"

13 comments:

dpugh said...

Thanks for putting this how-to guide together.

All of the registry keys used by the margins are of the form "StructureAdornment/ClassColor". The other keys (e.g. "Detect UTF8") are for other editor options. You should probably remove those from the list of keys to change for people who want to copy your configuration.

Marc said...

Thanx for this! I use a dark theme too, and it's definitely more useful now.

To make the reg file work in Win7, I had to include "Windows Registry Editor Version 5.00" at the top of the file.

Hopefully that saves someone else from GooBing it.

Daryl said...

Thanks Marc for the tip. I've updated the file post.

Craig S. said...

If anyone is wondering, this Extension can be "hacked" to work on VS2012. :D I was really missing this extension in VS2012 and just had to have it....

Daryl said...

@Craig S. Do you have walk though for how to "hack" it? I deeply desire this in VS2012 as well

Craig S. said...

1. Your captcha sucks...sorry, but I can't read any of them. So if this posts, it'll be a miracle.

2. This extension is no longer on visualstudiogallery.com. Luckily, I liked it so much, I had downloaded it. It's my understanding that much of this functionality is in the Productivity Power Tools, but frankly, the implementation of the enhanced scrollbar doesn't compare to this extension. Also, this means that this extension will not be available for VS2012. Well, I grabbed the original source code and I was able to update the extension so that it will install into VS2012 (YAY!!!). It took me a while, and simply installing the modified AllMargins.vsix didn't seem to work right, so I installed each component individually. But, it does work; I did not need to change a single line of code.

Craig S. said...

Ah, sorry, I see my comment did get through :)

Well, VSIXs are zip files. There's actually a MSDN article that shows how to update extensions from VS2010.

Basically, I had to update the *.vsixmanifest XML files so that the supported VisualStudio Edition contained version 11.0.

Also, (not mentioned in the MSDN article), I updated the MaxSupportedFramework attribute to 4.5.

All the projects in the source code need to be re-targeted and compiled against the .NET 4.5 Framework. You also need to update some references to VS 11.0, i.e. Microsoft.VisualStudio.Shell.11.0.dll, is one example (there are more).

Then recompile the solution. Finally, like I previously commented, for some reason, when I double-clicked AllMargins.vsix, it installed successfully, but the "child extensions" were not installed--so I got an exception when I started VS2012. NP, though, because I ran into this a few times. Just install each individual extension separately (in dependency order) and everything will just work.

HTH.

Daryl said...

@Craig S. Thanks for the instructions... I'm having trouble finding the all margins extension any more, and only found this older 2.3 version http://archive.msdn.microsoft.com/OverviewMargin/Release/ProjectReleases.aspx?ReleaseId=3957
Do you happen to know where the latest version is?

Craig S. said...

I'll try to blog better instructions tonight.

Craig S. said...

@Daryl: That's what I grabbed. That's "the latest". It hasn't been updated in forever, but then again, it's just that good ;) Hehe.

Craig S. said...

I just posted a more detailed blog post outlining the steps I took. I'm posting a link here in case someone else needs these instructions and comes across your blog. Updating Visual Studio 2010 Extensions for Visual Studio 2012. Hope this helps someone else.

Jeff V said...

@Craig S - Can you share your rebuilt .vsix somewhere? I was in the middle of doing the exact same thing myself, but mine has an odd visual glitch where the left and right curly-braces font gets like 1/2 normal size whenever structure adornment touches it.

Jeff V said...

@Craig S - Nevermind, Apparently my issue was that SyntacticFisheye was enabled, so shrank all lines with no alpha-numeric characters to 50%. Anyway, I too converted it to work with VS2012, and posted the .vsix on my blog: http://wp.me/p2C3ej-V