次の方法で共有


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 = RGB(128,0,0) 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.

Comments

  • Anonymous
    November 15, 2004
    For which version of VS.NET does this apply? 2002? 2003? 2005?

  • Anonymous
    November 15, 2004
    Oh, just read... shame on me, sorry :-)

  • Anonymous
    November 15, 2004
    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

  • Anonymous
    November 15, 2004
    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.)

  • Anonymous
    November 16, 2004
    Nice timing , i was searching it recently...

    Thanks a lot

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

  • Anonymous
    November 18, 2004
    The comment has been removed

  • Anonymous
    November 18, 2004
    Note the typo:
    Guides = RBG(128,0,0) 5, 80
    should be RGB, I assume.

  • Anonymous
    November 18, 2004
    On Visual Studio 2003, you should use

    [HKEY_CURRENT_USER]SoftwareMicrosoftVisualStudio7.1Text Editor
    Guides=RGB(192, 192, 192) 80

    Be care about the space between Text and Editor !

    Regards

  • Anonymous
    November 22, 2004
    Alain

    No effect on my Visual Studio 2003

  • Anonymous
    November 22, 2004
    The comment has been removed

  • Anonymous
    November 22, 2004
    Depends also on background - using default white (default on my system), RGB(255,252,252) will produce white guidelnes on white background - not much to see there, except through selection :-)

    Change the colour.

  • Anonymous
    November 23, 2004
    The comment has been removed

  • Anonymous
    November 23, 2004
    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?

  • Anonymous
    November 25, 2004
    The comment has been removed

  • Anonymous
    November 29, 2004
    Hi Clinton,

    RGB(255, 252, 252) 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

  • Anonymous
    November 30, 2004
    May I suggest that someone should post a screenshot for this?

    Thanx,
    zeddock

  • Anonymous
    November 30, 2004
    Yep, that can be arranged. I'll update the post with a picture.

  • Anonymous
    November 30, 2004
    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.

  • Anonymous
    December 02, 2004
    Post updated with image. Thanks!

  • Anonymous
    December 02, 2004
    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.

  • Anonymous
    December 03, 2004
    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.

  • Anonymous
    January 11, 2005
    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....

  • Anonymous
    April 10, 2005
    The comment has been removed

  • Anonymous
    April 10, 2005
    The comment has been removed

  • Anonymous
    April 11, 2005
    It actually works in VS 2003 too.

  • Anonymous
    June 26, 2005
    Many thanks to Craig for pointing out thsi very useful (hidden) feature of Visual Studio:


    Via...

  • Anonymous
    July 01, 2005
    Now here is a feature that we should expose far more prominently (and I'll push the core team to do so)...

  • Anonymous
    July 06, 2005
    Now here is a feature that we should expose far more prominently (and I'll push the core team to do so)...

  • Anonymous
    July 10, 2005
    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

  • Anonymous
    July 12, 2005
    The comment has been removed

  • Anonymous
    August 10, 2005
    I am using VS 6.0 and want to add Guidlines in it. I am not able to do so.

  • Anonymous
    August 26, 2005
    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.

  • Anonymous
    November 01, 2005
    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]SoftwareMicrosoftVisualStudio8.0Text Editor

    but under

    [HKEY_CURRENT_USER]SoftwareMicrosoftVCExpress8.0Text Editor

    Hopefully there will be a straightforward configuration option in later versions of VS rather than modifying the registry manually.

  • Anonymous
    November 09, 2005
    Very useful feature! The first thing I tried to do was make guidelines of different colors:
    [HKEY_CURRENT_USERSOFTWAREMicrosoftVisualStudio8.0Text Editor]
    "Guides"="RGB(200,200,255) 2,RGB(255,200,200) 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

  • Anonymous
    January 17, 2006
    Yes, this is a very good feature, and I would more like a underline for currentline in editor, does it possible?

  • Anonymous
    February 04, 2006
    PingBack from http://blergh.wordpress.com/2006/02/05/links-for-2006-02-04/

  • Anonymous
    March 07, 2006
    The comment has been removed

  • Anonymous
    April 14, 2006
    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.

  • Anonymous
    April 27, 2006
    The comment has been removed

  • Anonymous
    May 19, 2006
    Любой профессиональный текстовый редактор умеет показывать правую границу "полей" (Right Margin). Встроенный...

  • Anonymous
    August 08, 2006
    The comment has been removed

  • Anonymous
    August 08, 2006
    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.

  • Anonymous
    August 09, 2006
    The comment has been removed

  • Anonymous
    August 10, 2006
    Codeproject上有一个关于代码宽度的调查http://www.codeproject.com/script/survey/detail.asp?survey=590

  • Anonymous
    August 11, 2006
    PingBack from http://www.magerquark.de/blog/archive/379

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

  • Anonymous
    August 31, 2006
    A nice feature to verify coding styles: Guidelines . Missed this one in the previous VStudio.

  • Anonymous
    September 22, 2006
    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

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

  • Anonymous
    January 03, 2007
    Adding Guides to Visual Studio

  • Anonymous
    February 05, 2007
    see: http://blogs.msdn.com/saraford/archive/2004/11/15/257953.aspx

  • Anonymous
    February 27, 2007
    在vs.net 2005 编辑器中设置一条代码边界线,以防止自己的代码行写的过长。

  • Anonymous
    April 01, 2007
    The comment has been removed

  • Anonymous
    August 27, 2007
    PingBack from http://pessoa.fct.unl.pt/p110371/blog/getting-the-80-column-marker-on-visual-studio/

  • Anonymous
    January 25, 2008
    PingBack from http://olalindberg.com/blog/2008/01/26/80-column-guidelines-in-visual-studio-express/

  • Anonymous
    December 02, 2008
    The comment has been removed

  • Anonymous
    February 21, 2009
    PingBack from http://blog.geeky.cc/post/2009/02/Visual-Studio-Guidelines.aspx