Eric Hammersley

<insert impressive list of technology to blog about here>

  Home  |   Contact  |   Syndication    |   Login
  92 Posts | 0 Stories | 198 Comments | 311 Trackbacks

News

Subscribe in NewsGator Online

Thawte WOT Notary
Serving Southern Indiana


Archives

Post Categories

Blogroll

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

Feedback

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford) 11/14/2005 8:25 AM Brian
That's totally cool!

Works for me!

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

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

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

# re: Guidelines in Visual Studio 2002, 2003 and 2005 text editors (Thanks to Channel 9 and Sara Ford) 6/22/2009 2:44 AM asdf
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.

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

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: