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.
Manually edit .sln file
This method is entirely aimed at renaming the directory for the project, as viewed in Windows Explorer.
This method does not suffer from the problems in the Remove/add project file method below (references disappearing), but it can result in problems if your project is under source control (see notes below). This is why step 2 (backup) is so important.
- Close Visual Studio.
- Create a backup of your .sln file (you can always roll back).
- Imagine you want to rename directory
Project1
to Project2
.
- If not using source control, rename the folder from
Project1
to Project2
using Windows Explorer.
- If using source control, rename the folder from
Project1
to Project2
using the functions supplied by source control. This preserves the history of the file. For example, with TortoiseSVN
, right click on the file, select TortoiseSVN .. Rename
.
- In the .sln file, edit all instances of
Project1
to be Project2
, using a text editor like NotePad.
- Restart Visual Studio, and everything will work as before, but with the project in a different directory.
You can also see renaming solution manually or post which describes this manual process.
Advantages
- You can make the directory within Windows Explorer match the project name within the solution.
- This method does not remove any references from other projects to this file (an advantage over the Remove/add project file method, see my other answer below).
Warnings
- It's important to back everything up into a .zip file before renaming anything, as this method can create issues with source control.
- If your project is under source control, it may create issues if you rename files or
directories outside of source control (using Windows Explorer). Its preferable to rename the file using the source control framework itself, if you can, to preserve the history of that file (check out the context menu on a right click - it may have a function to rename the file).
Update 2014-11-02
ReSharper has added an automated method for achieving the same result as the manual method above. If the namespace is underlined with a squiggly blue line, click on the action pyramid icon to either:
- Rename the namespace to match the directory name in Windows Explorer, or;
- Rename the directory in Windows Explorer to match the namespace.
In the second case, the final word defines the new directory name in Windows Explorer, e.g. if we changed the namespace to ViewModel2
, it would offer to move the file to folder ViewModel2
.
However, this will not necessarily update files in source control, so you may still have to use the manual method.
Update 2018-01-31
Tested with Visual Studio 2008, 2010, 2012, 2013, 2015, 2017 Update 1, 2, 3, 4, 5.
Update 2020-05-02
Tested with Visual Studio 2019.
Best Answer
The VSCommands Lite extension appears to do this, judging by this blog post.
I don't think there's any way to do this other than using/writing an extension; macros don't appear to have access to the zoom controls.
If you wanted to write your own custom extension to do this you'd probably be looking at using the IWpfTextView interface.
Another good option is Presentation Zoom.