imageI have been using this Visual Studio extension called VS10x Code Map by Michael Kiss and I love it. It sits on the left or right of the Visual Studio text editor and provides an attractive outline view of the properties, methods, regions, etc in the current code file and lets you quickly navigate to a particular member.

I have tried other add-ins in the past that provided a code outline but they were usually slow, unattractive, or used a tree view style interface that I found to be more cumbersome than scrolling. The other nice thing about this one is that if you use regions (sorry Jeff, but to each his own) it will group your members by those regions.

It’s probably only useful if you have a wide-screen monitor since it does take up valuable screen real-estate. But according to the Visual Studio Extension Manager (Tools -> Extension Manager) it’s pretty popular.

I saw in my feed reader a posting that announced the release of the Visual Studio 2010 Pro Power Tools extension that was available in the Visual Studio 2010 Extension Manager. At first glance I thought it was the Power Tools extension that I’ve been using for a while. However, this is a totally separate extension that adds some very awesome features.

Note that they go into a lot of detail on the enhanced document tab feature but although this is neat and useful, it’s not really in my top 3 features. I’ve emphasized my 3 favorite features.

  • Document Well 2010 Plus
    • Tab Well UI
      • Scrollable tabs
      • Vertical tabs
      • Pinned tabs
      • Show close button in tab well
    • Tab Behavior
      • Remove tabs by usage order (LRU)
      • Show pinned tabs in a separate row/column
    • Sorting
      • Sort tabs by project
      • Sort tabs alphabetically
      • Sort tab well dropdown alphabetically
    • Tab UI
      • Color tabs according to their project or according to regular expressions
      • Miscellaneous options that modify tab UI
        • Show document/toolwindow icon in tab
        • Show close button in tab
        • Modify dirty indicator style
        • Modify minimum and maximum tab size
  • Searchable Add Reference Dialog
  • Highlight Current Line
  • HTML Copy
  • Triple Click
  • Fix Mixed Tabs
  • Ctrl + Click Go To Definition
  • Align Assignments
  • Colorized Parameter Help
  • Move Line Up/Down Commands
  • Column Guides

H3Viewer

Update: There was a bug in H3Viewer at the time I posted this that showed an empty TOC and Index on x64 versions of Windows. Rob Chandler just informed me the current build (1.0.0.20) fixes this and I have confirmed it now works fine on x64! Apparently in between Beta 2 and RC Microsoft may have changed the help agent from 32 bit to 64 bit which relocated some registry keys. H3Viewer is still a 32 bit application but works fine on 64 bit Windows.

I hate Visual Studio 2010’s new help system. Well hate isn’t really the right word. It’s more like loathing with every fiber of my being. There was a pretty good discussion going on in the comments of Brian Harry’s blog on MSDN. The bottom line is though, it’s here to stay.

Fortunately a Microsoft Help MVP named Robert Chandler has created H3Viewer which is an interface on top of the new help system that aims to bring back the familiar feel of dexplore, including a TOC, index, and bookmarks. It doesn’t change the fact that help is now served by a local web server but it’s a great improvement over the out of box experience. Sorry but IE/Chrome are not good help viewers.

imageI love the new per-application MRU list that appears when you right click a pinned taskbar item. As I mentioned in a previous post, this seems to be driven off the existing API’s that the shell and applications use to populate the “Recent Documents” list in previous versions of Windows.

One annoying thing I noticed was that Visual Studio solutions were never showing up in the MRU list for Visual Studio. In fact, nothing was. It took about 5 seconds before I realized “duh… solutions aren’t associated with Visual Studio”. They’re actually associated with a stub called “Visual Studio Version Selector” which looks inside the .sln file and launches the appropriate version of Visual Studio if it is installed on your machine.

Personally, one version of Visual Studio is big enough for me so I always run the latest (currently Visual Studio 2008). I don’t need this version selector. Right Click –> Open With just screwed up the icons and didn’t help the MRU list problem but there was a very simply registry fix to make .sln files associate with Visual Studio 2008.

Windows Registry Editor Version 5.00 
[HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln\Shell\Open\Command]
@="\"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe\" \"%1\""

Put the above in a .reg file or go into regedit.exe and do it by hand. If you need more instructions then the hack probably isn’t for you. Note that this will eliminate the ability to double click a .sln file and have it open in the version of Visual Studio that created it. But who really does that anyway.

I am a keyboard guy. I like to use keyboard shortcuts, I don’t like to waste time with the mouse. Especially when I am writing code. Today, for some stupid reason, I found myself making the mistake of hitting CTRL+HOME and jumping to the top of my source file when in fact I was trying to get to the top of a particular function. I’m not exactly sure why my brain started doing this, but rather than retrain myself, I decided to retrain Visual Studio.

Of course one of the things I love best about VS.NET is it’s incredible extensiblity mechanism. I’m not very skilled with it, but fortunately there are a bunch of sample macros already included. One of which did almost exactly what I wanted — BeginningOfFunction. I wanted to map this macro to CTRL+HOME.

But I also use CTRL+HOME an awful lot when I do want to get to the beginning of the document and I didn’t want to retrain myself there either. So I came up with what I think is a great compromise.

I made some minor modifications to the BeginningOfFunction macro that jumps to the beginning of the current function when you press CTRL+HOME, but if you press it again, it takes you to the beginning of the document. Pretty cool huh? Mapping it was pretty easy too. Below is the new source code of the BeginningOfFunction macro.

Sorry for the code formatting, it was a bitch to even get it this close.

'''
''' BeginningOfFunction moves the caret to the beginning of the containing
''' definition. If it is run twice in succession without any cursor movement,
''' then the cursor will move to the beginning of the document.
'''

Sub BeginningOfFunction()

    Dim textSelection As EnvDTE.TextSelection
    Dim codeElement As EnvDTE.CodeElement
    Dim gotoBeginning As Boolean = True
 
    textSelection = DTE.ActiveWindow.Selection
 
    Try

        ' See if we are in a function
        codeElement = textSelection.ActivePoint.CodeElement(vsCMElement.vsCMElementFunction)
 
        If Not (codeElement Is Nothing) Then

            ' Get the starting point of the function
            Dim functionPoint As TextPoint = codeElement.GetStartPoint(vsCMPart.vsCMPartHeader)
 
            ' Only do this if we're not already at the start of the function
            ' (for example if this is the second CTRL+HOME press)
            If Not textSelection.ActivePoint.EqualTo(functionPoint) Then

                ' Goto start of function
                textSelection.MoveToPoint(functionPoint)
                gotoBeginning = False

            End If

        End If

        If gotoBeginning Then
            ' Goto beginning
            textSelection.MoveToLineAndOffset(1, 1)
        End If

    Catch
    End Try

End Sub

Not sure if this is new or not, but this is such an awesome feature I had to blog about it. How many of you have Console.WriteLine or Debug.WriteLine or Trace.WriteLine statements cluttering up your code often for only temporary reasons? I just stumbled upon this tracepoint feature which works like a breakpoint except instead of breaking the code, it just writes a debug message optionally including variable values.

Right click a line of code (only tried C#), Breakpoint -> Insert Tracepoint.

o_SNAG-0180

Just wanted to pass on this VS.NET tip that you might find useful.

In the External Tools menu, I have added two commands:

Command Prompt in Solution
Command Prompt in Project

They are pretty simple to add, but valuable nonetheless. Here is how to add them.

Title: Command Prompt in Solution
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
Initial Dir: $(SolutionDir)

Title: Command Prompt in Project
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86
Initial Dir: $(ProjectDir)

The only difference of course being the initial directory, but it’s worth mentioning that the Arguments passed to the command processor will ensure that the environment variables for the .NET Framework get set correctly so that you can run compiler and other framework tools.