Adding a guideline to the editor in Visual Studio

Visual StudioIdeRegistry

Visual Studio Problem Overview


Introduction

I've always been searching for a way to make Visual Studio draw a line after a certain amount of characters.

Below is a guide to enable these so called guidelines for various versions of Visual Studio.

Visual Studio 2013 or later

Install Paul Harrington's Editor Guidelines extension.

Visual Studio 2010 and 2012

  1. Install Paul Harrington's Editor Guidelines extension for VS 2010 or VS 2012.
  2. Open the registry at:
    VS 2010: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor
    VS 2012: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor
    and add a new string called Guides with the value RGB(100,100,100), 80. The first part specifies the color, while the other one (80) is the column the line will be displayed.
  3. Or install the Guidelines UI extension (which is also a part of the Productivity Power Tools), which will add entries to the editor's context menu for adding/removing the entries without needing to edit the registry directly. The current disadvantage of this method is that you can't specify the column directly.

Visual Studio 2008 and Other Versions

If you are using Visual Studio 2008 open the registry at HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor and add a new string called Guides with the value RGB(100,100,100), 80. The first part specifies the color, while the other one (80) is the column the line will be displayed. The vertical line will appear, when you restart Visual Studio.

This trick also works for various other version of Visual Studio, as long as you use the correct path:

2003: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\Text Editor
2005: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor
2008: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor
2008 Express: HKEY_CURRENT_USER\Software\Microsoft\VCExpress\9.0\Text Editor

This also works in SQL Server 2005 and probably other versions.

Visual Studio Solutions


Solution 1 - Visual Studio

This is originally from Sara's blog.

It also works with almost any version of Visual Studio, you just need to change the "8.0" in the registry key to the appropriate version number for your version of Visual Studio.

The guide line shows up in the Output window too. (Visual Studio 2010 corrects this, and the line only shows up in the code editor window.)

You can also have the guide in multiple columns by listing more than one number after the color specifier:

RGB(230,230,230), 4, 80

Puts a white line at column 4 and column 80. This should be the value of a string value Guides in "Text Editor" key (see bellow).

Be sure to pick a line color that will be visisble on your background. This color won't show up on the default background color in VS. This is the value for a light grey: RGB(221, 221, 221).

Here are the registry keys that I know of:

Visual Studio 2010: HKCU\Software\Microsoft\VisualStudio\10.0\Text Editor

Visual Studio 2008: HKCU\Software\Microsoft\VisualStudio\9.0\Text Editor

Visual Studio 2005: HKCU\Software\Microsoft\VisualStudio\8.0\Text Editor

Visual Studio 2003: HKCU\Software\Microsoft\VisualStudio\7.1\Text Editor

For those running Visual Studio 2010, you may want to install the following extensions rather than changing the registry yourself:

These are also part of the Productivity Power Tools, which includes many other very useful extensions.

Solution 2 - Visual Studio

Without the need to edit any registry keys, the Productivity Power Tools extension (available for all versions of visual studio) provides guideline functionality.

Once installed just right click while in the editor window and choose the add guide line option. Note that the guideline will always be placed on the column where your editing cursor is currently at, regardless of where you right click in the editor window.

enter image description here

To turn off go to options and find Productivity Power Tools and in that section turn off Column Guides. A reboot will be necessary.

enter image description here

Solution 3 - Visual Studio

Visual Studio 2017 / 2019

For anyone looking for an answer for a newer version of Visual Studio, install the Editor Guidelines plugin, then right-click in the editor and select this:

Add guidelines in Visual Studio 2017

Solution 4 - Visual Studio

There is now an extension for Visual Studio 2012 and 2013:

http://visualstudiogallery.msdn.microsoft.com/da227a0b-0e31-4a11-8f6b-3a149cf2e459

Solution 5 - Visual Studio

If you are a user of the free Visual Studio Express edition the right key is in

HKEY_CURRENT_USER\Software\Microsoft\VCExpress\9.0\Text Editor

{note the VCExpress instead of VisualStudio) but it works! :)

Solution 6 - Visual Studio

This will also work in Visual Studio 2010 (Beta 2), as long as you install Paul Harrington's extension to enable the guidelines from the VSGallery or from the extension manager inside VS2010. Since this is version 10.0, you should use the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor

Also, Paul wrote an extension that adds entries to the editor's context menu for adding/removing the entries without needing to edit the registry directly. You can find it here: http://visualstudiogallery.msdn.microsoft.com/en-us/7f2a6727-2993-4c1d-8f58-ae24df14ea91

Solution 7 - Visual Studio

This works for SQL Server Management Studio also.

Solution 8 - Visual Studio

I found this Visual Studio 2010 extension: Indent Guides

http://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30

It works just fine. enter image description here

Solution 9 - Visual Studio

With VS 2013 Express this key does not exist. What I see is HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0 and there is no mention of Text Editor under that.

Solution 10 - Visual Studio

For those who use Visual Assist, vertical guidelines can be enabled from Display section in Visual Assist's options:

enter image description here

Solution 11 - Visual Studio

The registry path for Visual Studio 2008 is the same, but with 9.0 as the version number:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor

Solution 12 - Visual Studio

For VS 2019 just use this powershell script:

Get-ChildItem "$($env:LOCALAPPDATA)\Microsoft\VisualStudio\16.0_*" | 
Foreach-Object {
  $dir = $_;
  $regFile = "$($dir.FullName)\privateregistry.bin";
  Write-Host "Loading $($dir.BaseName) from ``$regFile``"
  & reg load "HKLM\_TMPVS_" "$regFile"
  New-ItemProperty -Name "Guides" -Path "HKLM:\_TMPVS_\Software\Microsoft\VisualStudio\$($dir.BaseName)\Text Editor" -Value "RGB(255,0,0), 80" -force | Out-Null;
   
  Sleep -Seconds 5; # might take some time befor the file can be unloaded
  & reg unload "HKLM\_TMPVS_";
  Write-Host "Unloaded $($dir.BaseName) from ``$regFile``"
}

Solution 13 - Visual Studio

You might be looking for rulers not guidelines.

Go to settings > editor > rulers > and give an array of character counts to provide lines at the specified values.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionxslView Question on Stackoverflow
Solution 1 - Visual StudioScott DormanView Answer on Stackoverflow
Solution 2 - Visual Studiorony lView Answer on Stackoverflow
Solution 3 - Visual Studiouser6269864View Answer on Stackoverflow
Solution 4 - Visual StudiobrianpeirisView Answer on Stackoverflow
Solution 5 - Visual StudioMiPView Answer on Stackoverflow
Solution 6 - Visual StudioNoah RichardsView Answer on Stackoverflow
Solution 7 - Visual StudioKeith WaltonView Answer on Stackoverflow
Solution 8 - Visual StudioDioView Answer on Stackoverflow
Solution 9 - Visual StudioeddyqView Answer on Stackoverflow
Solution 10 - Visual StudioPavel PView Answer on Stackoverflow
Solution 11 - Visual StudioRory MacLeodView Answer on Stackoverflow
Solution 12 - Visual StudioDaniel Fisher lennybaconView Answer on Stackoverflow
Solution 13 - Visual StudioSven VoigtView Answer on Stackoverflow