In my first column of this series I examined the new IntelliSense features in Visual Studio 2010. I consider those changes to be one of the two most significant in the history of Visual Studio. The second biggest change is, in my opinion, the new Breakpoints window. In this article I will show you three of the biggest changes made: labels, searching, and the new import/export abilities.

To get started exploring the changes, open up any sample code you have and set a few breakpoints like I have done in Figure 1. Where you set the breakpoints doesn’t matter so feel free to set them anywhere you like.

Using Labels

Prior to Visual Studio 2010 you could only sort on the column information that the IDE gave to you. For example, you could only sort by the name, condition, hit count, etc… If, for some crazy reason, you wanted to sort by anything else you were out of luck. Fortunately we now have a new column designed just for us-the labels column. Using this column you apply custom identifiers as you see fit.

There are two ways to apply labels to breakpoints. When you create the breakpoint just right-click it and choose Edit labels (Alt + F9, L) as shown in Figure 2. Also you can select one or more breakpoints in the Breakpoints window, then right-click, and choose Edit labels to accomplish the same result as shown in Figure 3.

The dialog (Figure 4) used to add labels to a breakpoint is pretty straightforward. Just type in a label and then click add and/or select one or more existing label names. Label names can be up to 64 characters each with no discernible upper limit to the number of names per breakpoint.

Take a moment and set labels for your sample breakpoints. For this simple example call some of them bubba and some of them ice cream as I have done in Figure 5.

The obvious, and most immediate, benefit of adding labels is you can now sort by the labels that you have assigned (Figure 6) rather than be at the mercy of only the data provided.

Labels empower you to do much more than just sorting. In the next section we will look at how labels, combined with the power of searching, supercharge your breakpoint experience.

Searching Breakpoints

Searching your breakpoints is another great feature in the new Breakpoints window. For quite some time developers asked for some way to search and filter breakpoints and this feature delivers on both counts. To see how it works, type in the letter B (case doesn’t matter) in the Search field of the toolbar (Figure 7) and press Enter.

Nothing appears to happen, right? Look at the Breakpoints window toolbar a little further to the right (Figure 8) and notice the default column to search is set to look at all visible columns.

Looking back at Figure 7 we can see that the letter B exists somewhere in every breakpoint. For example, all the breakpoints have the letter B in the Hit Count column. To get the results we are hoping for, change All visible to Labels in the In Column dropdown list as Figure 9 shows.

Notice this has the immediate effect of filtering your breakpoints and only showing those that match the criteria (Figure 10).

Now you have a filtered list of breakpoints. Here is one of the most important things to remember about the Breakpoints window: Virtually every action you take only acts on the results of the current search criteria. Put your mouse pointer over the button to delete all breakpoints (Figure 11).

What this means for you in real terms is you have newfound power over your breakpoints. In this case, for example, you could delete all the breakpoints that contain the letter B in their label but leave all the other breakpoints intact-something that has never before been possible.

I want to make a couple of more points about searching that is important. First, to clear any searches simply click the button to reset your search criteria located on the Breakpoints window toolbar as shown in Figure 12.

Second, as great as it is, at this time the search feature is a blunt instrument that doesn’t support logic operators (and, or, not), wildcards, or regular expressions.

Exporting and Importing

The last set of new features I want to show you are the export and import actions. Again, this is one of those features we have been clamoring about for some time and the Visual Studio team delivered for this newest version.

As you can see in Figure 13, the export and import (to the right of the export) buttons only act on the results of the current search criteria. In other words, make absolutely sure that all the breakpoints you want are showing up in the Breakpoints window.

Clicking on the export button allows you to export your current visible breakpoints in XML format to a text file. Once exported, they can be imported, checked into source control, manipulated with a script, or anything else you wish.

Contrary to popular belief, the ability to export your breakpoints was not created so you can make backups in case they are accidentally deleted. Exporting was added so you can share breakpoints with other team members working on the same code. Thus you should make sure a recent version of your exported breakpoints is included in source control with your code when you check it in.

Final Thoughts

The changes to the Breakpoints window are, in my opinion, some of the most significant changes ever in Visual Studio. Take time to explore the possibilities with the new labels, searching, and export/import features.