Dela via


Column Guides in Visual Studio

A lot of coding guidelines specify the maximum length for a line of code. For instance in the CLR, we like to keep lines of code under 110 characters long. Visual Studio has a feature which lets you display a vertical line at the column of your choosing to help visually see when a line is getting too long. This does involve mucking in the registry so the usual disclaimers apply.

To enable this feature, set:

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor]
"Guides"="RGB(192,192,192) 110"

The values passed to the RGB function let you specify the color of the line, and the number following tells Visual Studio at what column to display it. The settings above create a code editing window similar to:


(Click the image for a better look).

You can also create multiple guidelines by adding additional column numbers after the first one.

Comments

  • Anonymous
    July 07, 2006
    The comment has been removed
  • Anonymous
    July 07, 2006
    The comment has been removed
  • Anonymous
    July 09, 2006
    Thanks, I've been looking for something like this for some time. What would be even nicer is automatic support wrapping API documentation . . . do you know of any such ability / addins?
  • Anonymous
    July 10, 2006
    Thanks to Shawn Farkas for this little gem:http://blogs.msdn.com/shawnfa/archive/2006/07/07/659281.asp...
  • Anonymous
    July 10, 2006
    The best web page I know of for this sort of thing is Sara Ford's Visual Studio Tip of the Week (http://blogs.msdn.com/saraford/archive/category/9843.aspx).

    Not being on the VS team, I'm not sure why this is not in the Options UI :-)

    On the CLR, to automatically wrap comments, a lot of us use a macro that ships in the VS samples.  Bring up the Macro Explorer (Alt + F8), open up the SamplesVSEditor macros and check out FillCommentParagraph.  Editing the macro shows a comment which explains its purpose.  Or you can double click it to run it.

    -Shawn
  • Anonymous
    July 27, 2006
    For reflowing comments there is also Ian Nowland's add-in found at http://commentreflower.sourceforge.net/.
  • Anonymous
    August 09, 2006
    I've tried this one in Visual 2003 and it also works using the following registry path:

    [HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio7.1Text Editor]
  • Anonymous
    April 06, 2009
    The comment has been removed