SYSK 58: Making Code Line Length Conformance Easy in VS

Many teams agree on the maximum line length that should not be exceeded for code readability.  Usually, it’s either 80 or 120 characters long.  The question is, how do you conform to this rule?

Some of you may know this trick, but for those who don’t, there is an undocumented registry setting for VS2003 and VS2005 that will draw a vertical line in the VS editor of color and position that you specify.

I know it’s not as good as  the editor actually automatically breaking the line for you, but it’s the next best thing…

To make it happen, add the following registry key:
        For Visual Studio 2003:
         [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\Text Editor]
        "Guides"="RGB(255,0,0) 80, 120"

        For Visual Studio 2005:
         [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor]
        "Guides"="RGB(255,0,0) 80, 120"

Where the first value is the color of the line, the second is the column of the first line, and the third is the column of the second line.  The setting above will draw two red vertical lines at column 80 and at column 120.

You will need to restart VS…

Reference: archive/2004/11/15/257953.aspx

Comments (0)

Skip to main content