visual-studio 向 Visual Studio 中的编辑器添加指南
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/84209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding a guideline to the editor in Visual Studio
提问by xsl
Introduction
介绍
I've always been searching for a way to make Visual Studio draw a line after a certain amount of characters.
我一直在寻找一种方法让 Visual Studio 在一定数量的字符后画一条线。
Below is a guide to enable these so called guidelinesfor various versions of Visual Studio.
下面是为各种版本的 Visual Studio启用这些所谓的指南的指南。
Visual Studio 2013
视觉工作室 2013
Install Paul Harrington's Editor Guidelines extension for VS 2013
为VS 2013安装 Paul Harrington 的 Editor Guidelines 扩展
Visual Studio 2010 and 2012
Visual Studio 2010 和 2012
- Install Paul Harrington's Editor Guidelines extension for VS 2010or VS 2012.
- 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 calledGuideswith the valueRGB(100,100,100), 80. The first part specifies the color, while the other one (80) is the column the line will be displayed. - Or install the Guidelines UIextension (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.
- 为VS 2010或VS 2012安装 Paul Harrington 的 Editor Guidelines 扩展。
- 打开注册表:
2010 VS:HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Text Editor
VS 2012:HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Text Editor
加入一个名为新字符串Guides与价值RGB(100,100,100), 80。第一部分指定颜色,而另一部分 (80) 是该行将显示的列。 - 或者安装指南 UI扩展(它也是Productivity Power Tools的一部分),它将向编辑器的上下文菜单中添加条目,用于添加/删除条目,而无需直接编辑注册表。这种方法目前的缺点是不能直接指定列。
Visual Studio 2008 and Other Versions
Visual Studio 2008 及其他版本
If you are using Visual Studio 2008 open the registry at HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editorand add a new string called Guideswith 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.
如果您在使用Visual Studio 2008中打开注册表位置HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor,添加一个名为新字符串Guides与价值RGB(100,100,100), 80。第一部分指定颜色,而另一部分 ( 80) 是该行将显示的列。当您重新启动 Visual Studio 时,将出现垂直线。
This trick also works for various other version of Visual Studio, as long as you use the correct path:
这个技巧也适用于各种其他版本的 Visual Studio,只要您使用正确的路径:
2003: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.1\Text Editor
2005: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.0\Text Editor
2008: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.0\Text Editor
2008 Express: HKEY_CURRENT_USER\Software\Microsoft\VCExpress.0\Text Editor
This also works in SQL Server 2005 and probably other versions.
采纳答案by Scott Dorman
This is originally from Sara's blog.
这最初来自 Sara 的博客。
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.
它也适用于几乎所有版本的 Visual Studio,您只需要将注册表项中的“8.0”更改为适合您的 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.)
引导线也显示在“输出”窗口中。(Visual Studio 2010 更正了这一点,该行仅显示在代码编辑器窗口中。)
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 Guidesin "Text Editor" key (see bellow).
在第 4 列和第 80 列放置一条白线。这应该是Guides“文本编辑器”键中字符串值的值(见下文)。
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).
请务必选择一种在您的背景上可见的线条颜色。此颜色不会显示在 VS 中的默认背景颜色上。这是浅灰色的值: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 2010: HKCU\Software\Microsoft\VisualStudio\10.0\Text Editor
Visual Studio 2008: HKCU\Software\Microsoft\VisualStudio\9.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 2005: HKCU\Software\Microsoft\VisualStudio\8.0\Text Editor
Visual Studio 2003: HKCU\Software\Microsoft\VisualStudio\7.1\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:
对于运行 Visual Studio 2010 的用户,您可能希望安装以下扩展而不是自己更改注册表:
http://visualstudiogallery.msdn.microsoft.com/en-us/0fbf2878-e678-4577-9fdb-9030389b338c
http://visualstudiogallery.msdn.microsoft.com/en-us/7f2a6727-2993-4c1d-8f58-ae24df14ea91
http://visualstudiogallery.msdn.microsoft.com/en-us/0fbf2878-e678-4577-9fdb-9030389b338c
http://visualstudiogallery.msdn.microsoft.com/en-us/7f2a6727-2993-4c1d-8f58-ae24df14ea91
These are also part of the Productivity Power Tools, which includes many other very useful extensions.
这些也是Productivity Power Tools 的一部分,其中包括许多其他非常有用的扩展。
回答by rony l
Without the need to edit any registry keys, the Productivity Power Tools extension(available for all versions of visual studio) provides guideline functionality.
无需编辑任何注册表项,Productivity Power Tools 扩展(适用于所有版本的 Visual Studio)提供了指南功能。
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.
安装后,只需在编辑器窗口中单击鼠标右键,然后选择添加引导线选项。请注意,无论您在编辑器窗口中的何处单击鼠标右键,该指南都将始终放置在您的编辑光标当前所在的列上。
To turn off go to options and find Productivity Power Toolsand in that section turn off Column Guides. A reboot will be necessary.
要关闭,请转到选项并找到Productivity Power Tools并在该部分中关闭Column Guides。需要重新启动。
回答by rony l
Visual Studio 2017 / 2019
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:
对于寻找新版本 Visual Studio 答案的任何人,请安装编辑器指南插件,然后在编辑器中右键单击并选择:
回答by brianpeiris
There is now an extension for Visual Studio 2012 and 2013:
现在有 Visual Studio 2012 和 2013 的扩展:
http://visualstudiogallery.msdn.microsoft.com/da227a0b-0e31-4a11-8f6b-3a149cf2e459
http://visualstudiogallery.msdn.microsoft.com/da227a0b-0e31-4a11-8f6b-3a149cf2e459
回答by brianpeiris
If you are a user of the free Visual Studio Express edition the right key is in
如果您是免费 Visual Studio Express 版本的用户,则正确的键在
HKEY_CURRENT_USER\Software\Microsoft\VCExpress.0\Text Editor
{note the VCExpress instead of VisualStudio) but it works! :)
{注意 VCExpress 而不是 VisualStudio)但它有效!:)
回答by Noah Richards
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 VSGalleryor from the extension manager inside VS2010. Since this is version 10.0, you should use the following registry key:
这也适用于 Visual Studio 2010(Beta 2),只要您安装 Paul Harrington 的扩展以启用来自 VSGallery或来自 VS2010 内的扩展管理器的指南。由于这是 10.0 版,您应该使用以下注册表项:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.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
此外,Paul 编写了一个扩展,可以将条目添加到编辑器的上下文菜单中,以便添加/删除条目,而无需直接编辑注册表。你可以在这里找到它:http: //visualstudiogallery.msdn.microsoft.com/en-us/7f2a6727-2993-4c1d-8f58-ae24df14ea91
回答by Keith Walton
This works for SQL Server Management Studioalso.
回答by Dio
I found this Visual Studio 2010 extension: Indent Guides
我找到了这个 Visual Studio 2010 扩展:Indent Guides
http://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30
http://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30
回答by eddyq
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.
对于 VS 2013 Express,此密钥不存在。我看到的是 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0 并且下面没有提到文本编辑器。
回答by Rory MacLeod
The registry path for Visual Studio 2008 is the same, but with 9.0 as the version number:
Visual Studio 2008 的注册表路径相同,但版本号为 9.0:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio.0\Text Editor


