Adding vertical guides to the Visual Studio text editor

Something that I’ve done and liked since VS2005, has been to add vertical guides to the VS text editor. For example:

image

I like putting them at the first several tab stops as it helps keep track of indenting. I also have one at position 79 so I know where to wrap lines and comments. So, how do you do this? Well, it’s a registry entry. Here are the entries for each version of Visual Studio:

Visual Studio 2005:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0Text Editor]
"Guides"="RGB(230,230,255) 4, 8, 12, 16, 20, 24, 28, 32, 79"

Visual Studio 2008:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio9.0Text Editor]
"Guides"="RGB(230,230,255) 4, 8, 12, 16, 20, 24, 28, 32, 79"

Visual Studio 2010:

Bad news, here. Since the text editor is VS2010 is now a WPF control – this same registry entry doesn’t have any affect. If I find the equivalent of this for VS2010, I will try to post it up here.

UPDATE (4/24/2010): I found this was reported for VS2010, but it will not be implemented. Although there is a link in there of how you might be able to write your own extension that does this. See: https://connect.microsoft.com/VisualStudio/feedback/details/490930/text-editor-guides

Meanwhile, I just found that on the Visual Studio Gallery, someone implemented this. It’s just a quick download and the same registry entry (exception "10.0" vs "8.0", below) works!!!

Download: http://visualstudiogallery.msdn.microsoft.com/en-us/0fbf2878-e678-4577-9fdb-9030389b338c

You can either go modify the registry by hand (WARNING: standard “do not modify the registry!” warnings apply) – or you can copy/paste the contents above into a text file and name it something like “VerticalGuides.reg” – then double-click it to run it.

Also, the RGB is what you might expect – this is what sets the color of the line. So (255,0,0) is all red, (0,255,0) is all green, and (0,0,255) is all blue – and combinations of those are somewhere in-between. After that, the comma-separated list is a list of the vertical positions where you want the actual lines.

Lastly, to remove the guides, just create another file called “RemoveVerticalGuides.reg”, paste the contents below and double-click to run:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0Text Editor]
"Guides"=-

Setting a value to “-“ in a .reg file deletes that entry. Anyhow, I find this very useful so I thought I would post it.

Posted in Uncategorized, Visual Studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Archives
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 9 other followers

%d bloggers like this: