Guidelines – a hidden feature for the Visual Studio Editor

Update 12/2/2004:  Uploaded an image from Visual Studio 2005 Beta.  Note the image below shows guidelines at column numbers 5 and 30, but the regkey value is RBG(255,0,0), 4, 29.  The Guideline column numbers are 0-based in the registry.

 

Update 11/29/2004: I've corrected the two (embarrassing) typos below.  I must have had thanksgiving dinner on the brain at the time.  1.  The reg key is [HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\8.0\Text Editor (note the space between Text and Editor).  2. It's RGB, not RBG.  The example had a typo, but it is now corrected.

 

Guidelines at columns 5 and 30

 

Guidelines are visible column indicators for the VS Editor.  During the last test pass, I came across a test case named “Guidelines” which got my immediate attention.   I never heard of this before, so I made sure to spend extra time testing this cool, but hidden little feature during the Beta test pass.  I didn’t find any issues with it, so I feel it is safe to share.  Let me know if you run into any issues with it.

 

Warning!   To enable guidelines, you’ll need to modify your registry settings.   Follow the instructions below at your own risk.

 

Enabling Guidelines

 

First, shut down Visual Studio 2005 if already started.

 

Under

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

Create a string value called

Guides

 

Set Guides to the following

RGB(x,y,z) n1,...,n13

Where x,y,z are the RGB values and n is the column number.  You can have at most 13 guidelines.

 

For example,

Guides = #800000 5, 80

will place a Red guideline at column numbers 5 and 80.

 

And now launch VS and open a text file.

 

Disabling Guidelines

 

An obvious no-brainer, just delete the Guides keys you created above.  Restart VS, and no more guidelines.

Posted: Monday, November 15, 2004 5:49 PM by saraford
Filed under: Editor

Comments

VSEditor's WebLog said:

# November 15, 2004 8:54 PM

Uwe Keim said:

For which version of VS.NET does this apply? 2002? 2003? 2005?
# November 15, 2004 9:26 PM

Uwe Keim said:

Oh, just read... shame on me, sorry :-)
# November 15, 2004 9:27 PM

sara ford said:

It will work on Visual Studio .NET 2003 and should work on Visual Studio .NET 2002, but use at your own risk on either. I tested that it does work on 2003, but very little, so i can't ensure product stability using guidelines there. And i have *not* tested it at all on 2002, but the notes i have say it should work there.

If you encounter an issue on any version, let me know.

-sara
# November 15, 2004 10:34 PM

Di .NET e di altre amenita' said:

# November 16, 2004 3:49 AM

Andreas Häber said:

Guidelines? Brilliant!

I've often thought that such a feature would be nice to have, happily some dev at the VS team thought about that too. I'll let you know when/if it crashes ;) (I'm using VS2003 btw.)
# November 16, 2004 4:37 AM

Black Fox said:

Nice timing , i was searching it recently...

Thanks a lot
# November 16, 2004 10:06 AM

Carl Daniel [VC++ MVP] said:

Just the sort of thing to go into "VS PowerToys"... (where'd I see that idea kicked around...?)
# November 17, 2004 10:52 PM

Steven Cohn said:

Seems to work OK, but I can't seem to alter the color. Regardless of RGB values, it always draws a black dotted line.
# November 18, 2004 12:25 PM

BillT said:

Note the typo:
Guides = RBG(128,0,0) 5, 80
should be RGB, I assume.
# November 18, 2004 1:06 PM

The Emission Locus said:

# November 18, 2004 6:17 PM

The Emission Locus said:

# November 18, 2004 6:18 PM

Alain said:

On Visual Studio 2003, you should use

[HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\7.1\Text Editor
Guides=#c0c0c0 80

Be care about the space between Text and Editor !

Regards
# November 19, 2004 12:11 AM

Jasper22 said:

Alain

No effect on my Visual Studio 2003
# November 22, 2004 11:03 AM

OdeToCode Link Blog said:

# November 22, 2004 4:42 PM

Clinton Gallagher said:

RegEdit:
[HKEY_CURRENT_USER]\Software\Microsoft\VisualStudio\8.0\TextEditor
Edit > New > String Value: Guides
Edit > Modify > Value Data: #fefcfc 4

Results in no change for either VS2003 or VS2005.

Modified Value Data As: =#fefcfc 4 does not produce results either.

Ironically, just this morning before reading this blog item I sent a suggestion to MSDN Feedback Center asking for the addition of 'status' when backspacing to prevent the annoying backspace to previous line which happens when backspacing past the 0th column which I am too blind to see perceptively.

Guidelines would do I suppose but again, they do not function for me and I believe I have modified the registry correctly as shown above. Please advise.

csgallagher@REMOVETHISTEXTmetromilwaukee.com
# November 22, 2004 2:37 PM

Jože Marinček said:

Depends also on background - using default white (default on my system), #fffcfc will produce white guidelnes on white background - not much to see there, except through selection :-)

Change the colour.
# November 22, 2004 10:21 PM

ISlavoF.Save() said:

# November 23, 2004 8:17 AM

Harry Bosch said:

Works nicely on VS2003, but not heavily tested yet. One suggestion (which may not apply with VS2005): The guide line shows up in the Output window too, which I find distracting. I'd like it to show up in my documents only, I don't want them in the Output window.
# November 23, 2004 8:10 AM

RichB said:

Works OK for me in VS2003 - however I have no idea what use they'd be.

Sara - What does the Guidelines spec say is the intended usage scenario?
# November 24, 2004 1:05 AM

Alain said:

RichB

I will use this feature to prevent me when I write more than 100 char in one line.
My source will be more readable and printable.
# November 26, 2004 5:21 AM

sara ford said:

Hi Clinton,

#fffcfc shows a white guideline. If you go to Tools Options - Fonts and Colors - Text Editor, and change the Text background to black, you'll see the white guideline.

thanks!
-sara
# November 29, 2004 12:06 PM

zeddock said:

May I suggest that someone should post a screenshot for this?

Thanx,
zeddock
# November 30, 2004 10:57 AM

sara ford said:

Yep, that can be arranged. I'll update the post with a picture.
# November 30, 2004 11:11 AM

Mike Dunn said:

Nice. It works fine in VC 7.1 for me. I had been using the Visual Assist guideline feature, but that has funny redraw problems when you scroll w/the wheel. This built-in one looks better.
# November 30, 2004 6:26 PM

sara ford said:

Post updated with image. Thanks!
# December 2, 2004 2:00 PM

Kenny said:

As a user of several editors that expose an equivalent feature, the definition of the column numbers actually seems quite intuitive to me. The position of the guide is usually defined as being displayed *after* the specified column. Defining "4 29" in your example would create guides after column 4 and after column 29, which is exactly what your screenshot shows.

This is a feature that I've always missed in Visual Studio. I was especially happy to see that it also works in VS 2003, although I agree that it would be nice to have it only in the source code windows and not in the output window.
# December 3, 2004 7:36 AM

sara ford said:

I couldn't agree more with just having the guidelines show in the source code, and not in the command window, output window, etc (any tool window that contains an VsTextView editor).

I'm recording all these suggestions, comments and feedback for the next version.
# December 3, 2004 9:21 AM

Jed Blog said:

# December 21, 2004 4:03 AM

baris's blog said:

Guidelines – a hidden feature for the Visual Studio Editor An obvious no-brainer, just delete the Guides keys you created above. Restart VS, and no more guidelines....
# January 12, 2005 7:04 AM

The Emission Locus said:

# January 15, 2005 4:55 AM

Nate's Blog said:

# January 22, 2005 6:17 PM

Angelos Petropoulos' WebLog said:

# February 9, 2005 11:01 AM

Tom Seddon said:

The text needs to be drawn on top of the guidelines rather than the other way around. Particularly distracting if you have guidelines that are closer to the background colour than the text colour.

This doesn't affect all fonts; only those that are flush with the left edge of their bounding box as far as I can tell. (I have a couple of bitmap fonts that are like this, having the spare column on the right- rather than the left-hand edge.)
# April 10, 2005 10:59 AM

Tom Seddon said:

Sorry, should add:

1. Obviously the feature works for me (VS.NET 2002);

2. I noticed the 'lines on top of text' because I was trying out having guidelines at each tab stop. It would be handy for future revisions of the editor to not necessarily draw text on guidelines but perhaps when programming in languages that have curly braces draw a vertical line to the corresponding matching curly brace when the cursor is on a curly brace. The editor "scite" does this, and it's dead handy.
# April 10, 2005 11:02 AM

Thomas Due said:

It actually works in VS 2003 too.
# April 11, 2005 8:37 AM

Jan Schreuder on .Net said:

# April 20, 2005 3:08 AM

Wintellog said:

# June 24, 2005 10:13 PM

CraigBlog said:

# June 26, 2005 9:05 AM

Digital Thoughts said:

Many thanks to Craig for pointing out thsi very useful (hidden) feature of Visual Studio:


Via...
# June 27, 2005 4:37 AM

How Things (Should) Work said:

# June 28, 2005 9:13 PM

BorisJ's Blog said:

Now here is a feature that we should expose far more prominently (and I'll push the core team to do so)...
# July 1, 2005 5:49 PM

BorisJ's Blog said:

Now here is a feature that we should expose far more prominently (and I'll push the core team to do so)...
# July 6, 2005 9:55 PM

Nate's Blog said:

I just happened to stumble onto this
useful piece of information today. There is a hidden guidline feature
in Visual Studio 2003. This isn't all that important to most people
anymore since code is rarely edited on a 80 column display but it is a
nice
# July 10, 2005 5:21 PM

Opher said:

Well, I've read the post, the updates and the comments. No one has suggested the obvious: This is good so make it official! Put it in the product, as an Option, with a real UI and a dialog box (maybe even a PREVIEW?) that will be documented, supported, etc. I suspect no one reading these blogs is timid about editing the registry, but how about "casual" programmers? How about the VS Express products - does this "hidden feature" work? Wouldn't the whole VS product line be "better" with guidelines as a 'feature' rather than a 'hack'?
# July 12, 2005 10:59 PM

Wouter van Vugt said:

# July 18, 2005 3:07 AM

Wouter van Vugt said:

# July 18, 2005 3:16 AM

Tanveer said:

I am using VS 6.0 and want to add Guidlines in it. I am not able to do so.
# August 11, 2005 4:40 AM

mrk said:

A command to toggle the display of guidelines in the text editor could be useful too, bind it to a key to view when you want guidance.
# August 26, 2005 6:35 PM

Tobias said:

Thanks a lot! Those guidelines work perfectly within Visual C++ 2005 Express Edition August CTP, too. You just have to create a string value called Guides (using the information above) not under

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

but under

[HKEY_CURRENT_USER]\Software\Microsoft\VCExpress\8.0\Text Editor

Hopefully there will be a straightforward configuration option in later versions of VS rather than modifying the registry manually.
# November 1, 2005 4:37 PM

Chris Christodoulou said:

Very useful feature! The first thing I tried to do was make guidelines of different colors:
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\8.0\Text Editor]
"Guides"="#c8c8ff 2,#ffc8c8 4"
but VS only used the last color. It would be rather cool if multiple color guides were supported so when many guides are shown one wouldn't have to count them to find the right spot. Other than that, good stuff!

Cheers,

Chris
# November 9, 2005 12:39 PM

John Cui said:

Yes, this is a very good feature, and I would more like a underline for currentline in editor, does it possible?
# January 18, 2006 1:45 AM

Marcin Celej said:

# February 1, 2006 5:43 PM

Gorky said:

Quick tip if it's not working:

Make sure you set the registry value for *HKEY_CURRENT_USER* not HKEY_LOCAL_MACHINE which is what I tried at first and couldn't get it to work.  I typically head to local machine in the registry out of habit.
# March 7, 2006 4:13 PM

Eric Hammersley said:

# April 15, 2006 1:04 AM

bill said:

if you find it difficult to find some text editors , go http://www.yaodownload.com/web-authoring/web-design-utilities/cx-nav-bar/ , this is an excellent text editor.
# April 15, 2006 2:06 AM

Troy Scheffel said:

Thanks for the tip; works great (in VS2005 at least, I haven't tried it for VS.Net and hopefuly won't need to).  I've longed for this simple feature in VS.Net/2005.  All other good code editors I've used over the years had this feature.

Someone asked why you'd want this feature.  I use two lines, one set at column 77 which is where I start most line comments and one set at column 120 which indicates where no text should extend beyond (to prevent line wrapping during printing).  Thus, my Guides value is "#ff0000 76, 119" (255 = dark red).

ttfn
# April 27, 2006 10:22 AM

Неорганизованные Заметки Ремесленника said:

Любой профессиональный текстовый редактор умеет показывать правую границу "полей" (Right Margin). Встроенный...
# May 20, 2006 2:32 AM

Mythran said:

Is there another hack to perform the same thing, but horizontally?  How about having multiple guidelines with different colors for each?
# August 8, 2006 7:06 PM

Giuseppe Turitto said:

Thank You very much this is the most handy trick, Actually I tested for SQLmanager and works beautifull.

[HKEY_CURRENT_USER]/Software/Microsoft/Microsoft SQL Server/90/Tools/Shell/Text Editor/

and from there create the Guides String value, and everything its the same.
# August 8, 2006 7:54 PM

JDang said:

Very cool, thanks a lot guys. However, it also show the line in Command and Output windows of Visual studio 2005. Are there any way to turn it off. I just want the line in Codes window only.

JDang
# August 9, 2006 9:28 AM

武眉博 said:

Codeproject上有一个关于代码宽度的调查http://www.codeproject.com/script/survey/detail.asp?survey=590
# August 11, 2006 1:00 AM

Nihgwu said:

今天在http://www.codeproject.com/useritems/Guidelines.as...上看到的一编文章,是个很好的工具,也可以作为如何操作注册表的例子看一下。效果图如下:
# August 15, 2006 11:07 PM

Wouter van Vugt said:

A nice feature to verify coding styles: Guidelines . Missed this one in the previous VStudio.
# August 31, 2006 1:46 PM

Arvind said:

This question was once asked before in the forum but nover got answered. Is it possible to get these guidelines working for Visual Studio 6.0? If not natively supported is there any add-in available that will do the job. ~ Arvind
# September 23, 2006 7:49 AM

ploeh blog said:

From time to time, I've found myself wishing that Visual Studio had vertical guidelines in the code editor.


posted on 2006-12-21 11:55  心悦  阅读(451)  评论(0)    收藏  举报