Article: Visual Studio Tricks

Home Page


Consultancy

  • Service Vouchers
  • Escrow Service

Shop



Programming
  • Articles
  • Tools
  • Links

Search

 

Contact

 

Chess Puzzles




DWHS

Valid XHTML 1.0 Transitional
Valid CSS!
Mobile-friendly!

Some tricks to make life easier when using Visual Studio

category 'KB', created 23-Jun-2009, version V1.1 (06-Aug-2009), by Luc Pattyn


License: The author hereby grants you a worldwide, non-exclusive license to use and redistribute the files and the source code in the article in any way you see fit, provided you keep the copyright notice in place; when code modifications are applied, the notice must reflect that. The author retains copyright to the article, you may not republish or otherwise make available the article, in whole or in part, without the prior written consent of the author.

Disclaimer: This work is provided “as is”, without any express or implied warranties or conditions or guarantees. You, the user, assume all risk in its use. In no event will the author be liable to you on any legal theory for any special, incidental, consequential, punitive or exemplary damages arising out of this license or the use of the work or otherwise.


Sometimes we wish we could change Visual Studio's behavior. This little article lists a few tricks I have found useful.

User Selectable Settings

The user can change a lot of settings under menu Tools/Options. Here are some settings I strongly recommend:

  1. The first thing you should do is check the checkbox "Show All Settings", if unchecked half of the goodies remain hidden.
  2. Compilation errors and run-time exceptions often mention line numbers, and the Visual Studio editor is capable of showing line numbers, however for unknown reasons by default it does not do so. Turn the feature on by checking menu Tools/Options/Text Editor/All Languages/General: "Display Line Numbers".
  3. Sometimes Visual Studio does not show the Configuration Manager menu item, which allows you to select the build type (Debug, Release, etc). Check under menu Tools/Options/Projects and Solutions/General: "Show advanced build configuration".
  4. By default there are no shortcut keys to navigate to the next or previous find result. I recommend you add them like this:
    • choose menu Tools/Customize and click "Keyboard..." button
    • globally assign CTRL+SHIFT+F3 to Edit.GotoFindResults1NextLocation
      (type E to make that bloody small listbox scroll a bit closer to what you need)
    • globally assign CTRL+SHIFT+F2 to Edit.GotoFindResults1PrevLocation

Registry Tweaking

Other settings are not available through the dialogs, they require additions or modifications to the registry. The exact location in the registry depends on the specific version of Visual Studio you are using. I will use the notation [StudioBase] to symbolize that; it could equal something like

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1
HKEY_CURRENT_USER\Software\Microsoft\VBExpress\8.0
HKEY_CURRENT_USER\Software\Microsoft\VCSExpress\9.0
  1. Draw one or more vertical lines in editor windows, maybe to indicate where specific columns are, handy to restrict the source width. The example below added a REG_SZ to draw red vertical lines for columns 80 and 96:
    [StudioBase]\Text Editor\Guides=RGB(255,0,0) 80,96
    
  2. Tell Visual Studio to keep its tabbed documents in MRU order, with the most recently used one to the left; just add a REG_DWORD with value 1:
    [StudioBase]\UseMRUDocOrdering=1 (DWORD)
    

Source Code Tricks

  1. When the first class in a source file is a Component, such as a Control, Visual Studio will use a special icon, and double-clicking the file in the Solution Pane will open the file in Designer Mode. You can force it to open by default in an editor window by putting a single line in front of the class statement, like so:
    [System.ComponentModel.DesignerCategory("Code")]
    public class DoubleBufferedPanel : Panel {
    	...
    }
    


Perceler

Copyright © 2012, Luc Pattyn

Last Modified 02-Sep-2013