Column Guides
Visual Studio's column guides are simply dotted vertical lines that appear in code editor windows. These lines are positioned after a specified number of characters or columns as a visual guide to the length of the lines of code. They can be useful when you wish to keep your line lengths at or below a particular size. This may be because you wish to print your code without the text wrapping over multiple lines or because you adhere to a set of coding standards that include a line length restriction.
Column guides do not provide a barrier to the permitted length of lines. You can continue to type beyond the final guide with no affect on the code and with no reformatting applied by Visual Studio.
![Visual Studio Column Guide](images/VSGuide.png)
Adding Column Guides
Column guides are a hidden feature of Visual Studio and cannot be configured within the development environment. Instead, you must update the registry directly to enable them.
WARNING: This article deals with the registry, which is responsible for the configuration of your Windows system. Errors in the registry can leave your system inoperable. No responsibility for system damage can be accepted by BlackWasp should the methods describe cause issues. If you do not accept responsibility for using the methods described here, you must not use them. It is advisable to ensure that you have a recoverable backup of your system before making registry modifications.
Locating the Registry Key
The registry key that requires modification varies according to the version of Visual Studio that you are using. To find it, launch the registry editor and navigate to the following key:
HKEY_CURRENT_USER\Software\Microsoft\
Within this key will be a set of sub-keys. If you are using a full version of Visual Studio, one of these will be named "VisualStudio". However, if you are using the free-of-charge Express editions, you should see a key for each product that you have installed. For example, if you wish to add column guides to C# Express, you need to find the VCSExpress key. Open the appropriate key for your installation.
Next, you need to open another sub-key that relates to the version number of Visual Studio. For Visual Studio 2003, open the "7.1" key. For Visual Studio 2005, open "8.0". Finally, open the "9.0" key if you are using Visual Studio 2008. The numbering is the same for Express editions.
Finally, locate the sub-key "Text Editor". This is the key where you must create a new value. The full path of the key will be similar to the following:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor
Adding the Guides Value
The guide positions are defined using a string value in the format:
RGB(r,g,b) pos1 pos2 ...
The r, g, and b elements define the colour of the guide lines in a standard RGB format. Each integer value should be between zero and 255. The pos elements represent the character position of each guide. For example, if you wish to create two red guidelines at positions 105 and 110, you would use the string:
RGB(255,0,0) 105 110
To add the new value, right-click the Text Editor key. Select "New" and then "String Value" from the context-sensitive menu that appears. The new value will appear in the list on the right side of the registry editor window. Change the name of the value to "Guides".
To modify the value, right-click "Guides" and choose "Modify" from the menu. You can then enter the string value that you desire to specify the colour and positions of the guides. Once you have entered the value, click the OK button and restart Visual Studio. The guides should now be visible in code editors.
Editing and Removing Column Guides
If you wish to edit the colour or positions of the guides, modify the string value accordingly. To remove the guides altogether, delete the "Guides" value from the registry.
30 April 2009