Home > Shared Source, Visualization > Shared Source – Right Margin Line

Shared Source – Right Margin Line

September 24th, 2010

Good code style suggests limiting the length of a code line to 80 characters, and only 70 characters for indented code examples to be used in documentation. The Right Margin Line helps you to visually indicate the specified line length. It doesn’t prevent typing to the right of it, but lets you to identify and break long expressions over multiple lines.

CodeRush Right Margin Line preview

On the other side, Visual Studio has built-in margin line support. You can enable it via the registry editor in the following entry at:

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\%VS_VERSION%\Text Editor]

Where %VS_VERSION% is a version of the IDE you’re using, e.g. 10.0 (VS2010), 9.0 (VS2008), 8.0 (VS2005), 7.1 (VS2003).

The following string key should be added:

“Guides”=”RGB(64,64,128), 80”

The first part specifies the color, while the other one (80) is the column the line will be displayed. This will produce a blue margin line right before the 80th column. It looks pretty well on white and black backgrounds, but you can of course change it easily to any color and position. Note: the registry entry is different for Express editions of Visual Studio.

However, the Right Margin Line shipping with CodeRush Pro has a few more options you can specify on the “Editor | Painting | Right Margin Line” options page in the Options Dialog. You can specify not only line color, its opacity and position, but also line style and line width:

CodeRush Right Margin Line options page

The Right Margin Line feature is located inside an open source “CR_RightMarginLine” sample plug-in in the Shared Source solution of CodeRush. The feature is visual, so it is available on the DXCore Visualize toolbar:

CodeRush Right Margin Line Toolbar item

Products: CodeRush Pro
Versions: 9.1 and up
VS IDEs: any
Updated: Dec/07/2010
ID: C028

Similar Posts: