Geeks With Blogs

News

Subscribe in NewsGator Online

Thawte WOT Notary
Serving Southern Indiana



Eric Hammersley <insert impressive list of technology to blog about here>

Ever since I fired up Netbeans for the first time I have wanted the 80 column guideline it has in the text editor window.  Sure, there’s a control at the bottom of the text editor window that tells you where your cursor is column wise but honestly, a faint line right up column 80 works best.

Of course not everyone likes doing this but I’ve found that my code is the most readable visually and printed if I force breaks at 80 columns, or perhaps 120 columns.  Now, thanks to a Channel 9 post here and the original post by Sara Ford here I now know how to add guidelines in Visual Studio.  Why this isn’t an option in Tools… Options is beyond me.  Apparently it has been a hack for the past several versions.

Here’s how you do it.  Close Visual Studio and open up regedit.  Navigate to the key below inserting the version number of your VS install where appropriate (ie. for Visual Studio 2005 you’ll find an “8.0” key under the VisualStudio branch).

[HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\Text Editor

Now, create a new REG_SZ (String) value named “Guides” under the Text Editor branch.

Next, double click the new Guides key and insert the following text as its string value.

RGB(R,G,B) c1, c2… cn

where R, G, and B are the RGB values for the color you want the guideline to be.  Mine is set to 255,128,128 which gives you a faint red line that almost appears semi-transparent.  The values c1… cn are the column numbers you want guides to appear at.  NOTE: the column values you set in the registry are 0 (ZERO) based.  IOW, if you want guides at column 80 you’ll need to set it at 79.  You can have guidelines at as many columns you like, thus the cn.  :-)  Mine is set to 79, 119 because I want guide lines at 80 columns and 120 columns.

To bring it all together mine says.

RGB(255,128,128) 79, 119

I’ve attached a couple of images below to help visualize the whole process.  Click the image for a larger view.

Screen shot of registry location and string value to insert.

Regedit of Guides at 80 columns

 Screen shot of the 80 column guideline (VS2005).

Guidelines at 80 columns Posted on Thursday, November 10, 2005 10:02 AM Visual Studio 2005 | Back to top


Comments on this post: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
That's totally cool!

Works for me!
Left by Brian on Nov 14, 2005 8:25 AM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
Yeah, I love this tip. Very useful.
Left by Eric Hammersley on Nov 14, 2005 9:36 PM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
Thx very much.
Left by Ultiny on Jan 20, 2007 6:13 PM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
I tried in HKEY_LOCAL_MACHINE too. But it didn't worked. Why?
Left by Japs on Feb 29, 2008 1:47 AM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
Great tip, although you forget that visual studio's columns are 1-based, so you want to include column 80 on your line, for a total of 80 columns.
Left by asdf on Jun 22, 2009 2:44 AM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
I need this. Thanks a lot.
Left by Ly on Nov 24, 2009 1:51 AM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
Works like a charm, thanks a lot!

The columns really seem to be 0-based. Setting the value to 79 creates a vertical bar where the first character after the bar is in column 80.
Left by Eph on Jan 12, 2010 4:57 AM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
Wow, this is awesome! First google hit for `80 column guide visual studio`, congrats! I confirmed just now that this works in VS 2008 too!
Left by Adam on Jun 17, 2010 5:52 PM

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford)
Requesting Gravatar...
THIS IS IMPORTANCE FOR ME , WHEN YOU VOTE THE
KNOWLEDGE FOR US , THANKS
Left by hp on Jul 07, 2010 11:39 AM

Your comment:
 (will show your gravatar)


Copyright © Eric Hammersley | Powered by: GeeksWithBlogs.net