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 (8)

  1. Now there’s a nice ‘power feature’! Do you know of more of these Visual Studio hacks, or is there a website somewhere documenting these?

  2. Eric Wilson says:

    Stupid question, and I know you are probably not the person to ask this to, but for the love of God why is something this useful hidden in the registry?

  3. 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?

  4. shawnfa says:

    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

  5. Eric Smith says:

    For reflowing comments there is also Ian Nowland’s add-in found at http://commentreflower.sourceforge.net/.

  6. errodeika says:

    I’ve tried this one in Visual 2003 and it also works using the following registry path:

    [HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio7.1Text Editor]