Welcome to Null City Software
Tasty, tasty software.
Null City Logo Home Kitae Breeze Products Login Forums Contact Us About Us
Visual Studio is a huge sprawling mature application which has been around for a staggering 12 years. I use Visual Studio both at work and for my own projects, and I've been using it now for a good 8 of those 12 years. So I thought I'd pass on a few gems I've picked up along the way. See how many of these you already know.

In no real particular order.

10) Visual Studio 2002 had a Clipboard Ring dockable window that held a buffer of everything you copied in Visual Studio this allowed you to both view and rewind text you had copied in the editor. As far as I'm aware, the dockable Clipboard Ring window was removed. However, you still have access to this through a menu and shortcut key combination. In the editor, keep tapping CTRL+SHIFT+V to cycle through the clipboard ring.

9) Problem: You know the name of a file in your solution but you cant remember where it is? One Solution: using the find box on the Standard toolbar, type ">of [filename]" and as you type, Visual Studio will offer you a drop down of files in the solution that match what you are typing. Simply press up/down and enter to select the file you want to open.

8) It's quite easy to miss these buttons (sometimes mapped to Mouse Button 4 and 5 if you have them):

These are totally invaluable to me. Visual Studio keeps track of every document you move between and the location of the caret. These buttons allow you to move backwards and forwards through that history which is incredibly helpful in large projects.

7) Document Outline Window. This baby has been around for a while now, but is very easy to miss. If you do a lot of WinForms development this window should be on display at all times if you can squeeze it in because it makes renaming controls incredibly easy and allows you to view the hierarchy of your controls. This window can be reached through the View > Other Windows > Document Outline menu by default, or by pressing CTRL+ALT+T. If like me, you tend to build a whole user interface and then worry about renaming the controls after you've built it, then this window is for you. Build your UI as normal, then start from the top of the Document Outline window and work your way down to the bottom hitting F2 to rename your controls as you go.

6) Quick Watch - Probably the best place to test inline code while debugging. The QuickWatch window, which I generally remap the keyboard shortcut for to F9, will evaluate pretty much any code you type into it at run-time. When debugging, break into your code, select a chunk of code in the editor and Right Click > Quick Watch to display the Quick Watch window. Here you can tweak the expression and view its results.

5) Using the Toolbox as a snippet container. There will always be times whilst programming when you need to have more than one chunk of text in the clipboard. Visual Studio makes managing this situation very easy, simply create a new tab on the Toolbox by Right clicking in the empty space and selecting "Add Tab", give it a name and hit enter. Now simply drag and  drop code from any editor directly into the new tab. Nice huh? Additionally, once you've dropped code into the new tab you  can right click the item and rename it to something more useful if it's code you use frequently.

4) Some time ago, Microsoft added the "Tab Order" button to the WinForms designer, but it may have gone unnoticed by some.  Tab Ordering is very important for those of us who like to use the keyboard wherever possible, and is very good UI  practice to set up correctly. Whilst doing so is a complete pain in the ass, it is somewhat easier to manage with the "Tab  Order" item on the Edit Menu. When you have finished setting up a user interface in the WinForms designer, simply select  Edit > Tab Order and you will get an overlay on top of your user interface. Click each of your controls in the order you want them to activate when the TAB key is pressed by the end user. When done, select the Edit > Tab Order menu item again. The most annoying thing is, you still have to do it every time you insert a new control in the middle of your form, but hey, it's easier than doing it manually.

3) Modify those keyboard shortcuts to suit your own needs! Everyone knows where it is, Tools > Options > Environment > Keyboard, but very few people actually bother tailoring them to their own needs. This is a bit of a shame, because keyboard shortcuts set up properly can seriously speed up develepment and save on many hundreds to thousands of mouse clicks. No really, it pays dividends over time, and with the ability to export and save all your settings in seconds with the Import and Export wizard you only ever have to do it once, even across installations. Here are some of my favourites that I always remap:

ALT+Q - Insert Snippet
A hang over I have from QuickCode.NET). It's just easier.

ALT+S - View.ShowSmartTag
This is invaluable, you know that little smart tag that appears over your code when you don't have a namespace imported? View.ShowSmartTag opens that dropdown if you have the cursor over it, thus, ALT+S - Enter will import the namespace automatically for you.

CTRL+S - File.SaveAll
I remap the control + S shortcut to SaveAll because I instinctively jump around my code hitting CTRL+S to save, this way, everything gets saved at once and I've not lost any code since.

I've got loads of others that I remap but if you haven't already, spend some time in the options, there's stuff in there that could save you hours of work in the long run.

2) This one is a real life saver if you are developing an application with multiple entry points, such as client-server architectures. But if you just dont know it's there then you aren't using it. Number 2 is: launching multiple programs  with debug at the same time. I used many different ways around this before I realised it was there. I'm not sure whether the feature was added fairly recently (2005 maybe?), or whether it's just always been there and I never used it. Anyway I've been using it now for years in one place or another. If you have a project of any real size, you are almost certainly running more than one assembly. For those who don't know, Right Click your Solution root node and select "Set Startup Projects..."

In the following dialog simply pick "Multiple startup projects" and set the action to "Start" for all the applications you want to run with debugging.

1) Prematurely ending a build if a project in the solution failed. If you have a full release of Visual Studio (i.e. not Express or Game Studio) you have access to the Macros editor on the Tools menu. From here, in the default EnvironmentEvents VB module add the following code, save, and exit the macros editor.

    Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone
        If Not Success Then
        End If
    End Sub

The code above will kill the build if a project fails. Meaning you don't have to wait for the rest of the projects to fail before you can dig in and fix the problem. Useful!

Hopefully these little tips will help a few of you out there get a just a little bit more out of what is an absolutely fantastic editing package. Please drop me a comment if you find any of this useful, as I'd like to know whether to write more on related topics.
Rob - Null City Admin
Enter your own comment
Enter your name:

Enter your comment:

Null City Software
Null City is dedicated to developing top quality sofware products for Windows PC, XBox and Windows Phone. We specialise in games and .NET applications & components.