The opinions expressed in these materials are my own and are not necessarily those of Microsoft.
Copyright © Microsoft Corporation. All rights reserved. Unless otherwise indicated, all source code provided is licensed under the Microsoft Public License (Ms-PL).
This week I thought we would focus on some fun quickies that have been in Visual Studio since at least VS2010. The first one we will look at is simply zooming your text in the editor. The concept is really simple. For example, you may want to go from this:
Being able to zoom in and out is useful if you have trouble seeing or you are doing extreme programming or any situation where making text more readable is necessary. One other thing to keep in mind is that zooming is a per tab activity so zooming in one tab does not set the same zoom level in other tabs. Each tab has it's own zoom level.
You can zoom in and out of text using the wheel on your mouse. Just hold down CTRL+Mouse Wheel and you can instantly zoom in and out of text in the editor.
Most people discover this accidentally. If this annoys you then you can see if there is an update to the Disable Mouse Wheel Zoom extension:
At the time of writing there isn’t a version that works with VS2013 but that could change.
You can go “old school” and use the combo box at the bottom left of the IDE:
If you prefer to use the keyboard, you can always use CTRL+SHIFT+>[Greater Than] and CTRL+SHIFT+<[Less Than].
Hey Folks :)
Wanted to let you know that the Visual Studio 2013 and Team Foundation Server 2013 Release Candidates were made public today. Here is some guidance and information:
Please go to Soma’s blog for the main announcement today.
- Download Visual Studio 2013 RC
You can find more information including new features, platforms and compatibility, and much more here:
- Save the date for Visual Studio 2013 Launch on Nov 13th
Note: Windows Store app development requires Windows 8.1 RTM, which is available to MSDN and TechNet subscribers. Visual Studio 2013 RC does not support Windows 8.1 Preview or Windows Server 2012 R2 Preview. For more information, see system requirements and platform compatibility.
Direct feedback to the following locations:
- Connect (for bugs) & VS Feedback Tool (for bugs filed from within VS)
- UserVoice (for ideas/suggestions)
- Forums (for Q&A)
- Support (for in-production use only)
- You will also have the Send-A-Smile option in the product (the happy face in the upper-right corner), to send general thoughts and sentiment on the release.
My good friend, Kevin Remde, is writing a great series comparing VMWare technology to our Hyper-V offering. His latest post on the cost benefits was very compelling. Here is an excerpt from the post:
So today, for the latest article in our “VMware or Microsoft?” series, I thought I’d address an area that perhaps a lot of VMware customers don’t know much about. One of the important things that we really want VMware customers to understand is that they may be paying for features or technology or high availability or virtualized storage or virtualized networking that they wouldn’t have to if they went with Microsoft’s version of the “Software Defined Data Center”.
You can see the full article here:
If you have been following the blog then you know I am a HUGE fan of Brian Keller’s VS/TFS virtual machines. I personally use them to make sure folks can duplicate the techniques I show them in my posts. Earlier this month Brian announced the availability of the latest one: “Visual Studio 2013 Application Lifecycle Management Virtual Machine and Hands-on-Labs / Demo Scripts”
You can (and should) read the instructions for downloading the VM here:
NOTE: This is an older feature. I’ve updated the information for VS2013.
The Breakpoints Window (CTRL+ALT+B) is an awesome tool. We use it frequently to aid us in our debugging efforts. Let’s take a look at some of the things you can do when working in this window.
Getting rid of breakpoints is a common task. There are two main ways you can remove breakpoints using the Breakpoints Window.
This one is pretty simple. Select one or more breakpoints and click on the Delete The Selected Breakpoints button:
It will remove the selected breakpoint entries and you are good to go:
In my last post I showed you how to do a search with labels (or any column for that matter) and it turns out you can delete the results of a search. For example, if you have a set of breakpoints:
And have filtered them with search criteria:
You can delete the results of the search by using the Delete All Breakpoints Matching The Current Search Criteria button:
(Note: Using this button without having a search filter will delete all your breakpoints so use this button with caution)
Which will delete all visible breakpoints:
This does not impact breakpoints that were not part of the search result. You can verify this by clearing the search criteria:
In addition to deleting breakpoints you can export breakpoints based on the current search criteria (or all breakpoints if no search is set):
The exported breakpoints are saved to an XML file and can be imported later on:
Special Note: At the time of this writing my breakpoint export wasn’t working. This may be a bug in the VS2013 Preview or just my installation.
Make sure to take full advantage of the Breakpoints Window during your debugging efforts. Take some time to work with these techniques to save you time and frustration.
The Breakpoints Window has supported adding labels since VS2010, however most people aren’t aware of this feature. But how does this help you? Well, first, you can put friendly names for Breakpoints to make them easier to understand. Second, you can sort by the label names. And, third, you can search the labels when you have a lot of Breakpoints. Let’s see how to make this happen.
Go into any code base and create several breakpoints (F9) then open the Breakpoints Window (CTRL+ALT+B):
Notice the Labels column? It goes largely ignored unless someone points it out. To add a label to a single breakpoint just Right-Click it and choose Edit Labels:
Alternatively, you can select multiple breakpoints and do the same thing to create labels in bulk:
For this demo, select about half (or a little more) of you breakpoints and edit their labels. This will bring up the Edit Breakpoint Labels dialog:
Put in a label of “cart” to indicate these breakpoints are associated with our shopping cart and click add:
It turns out that these particular breakpoints are also associated with adding items to the cart so let’s put in another label of add item:
The point here being that you can add multiple labels to breakpoints. Click the OK button and notice the result:
Let’s assume the rest of the breakpoints deal with deleting items from the cart. Select them and edit the labels:
Since “cart” is already in our list of breakpoint labels we can simply select it:
Now we just add “delete item” to the list and we are all set:
Click OK and verify all the breakpoints have labels:
Now that we have set the labels we can sort by the labels column entries by click on the column header:
Everything looks in order but let’s make a change. Edit one of the “add item” entries to read “modify item”:
Take a look at your list again and notice how they are sorted:
The labels are sorted alphabetically from left-to-right so pay attention to your label names. In this example we have a potential issue since the word “cart” is keeping the sort from happening the way we want it. Fortunately for me, since they are all related to the cart, I can safely turn off the “cart” word and still have contextual meaning for my labels:
Now that we have good labels set up we can do more advanced activities. We can search by any column but searching by labels we designate is particularly powerful. For demo purposes I’m going to make a point about searching you need to pay attention to. We want to find all the “add item��� breakpoints. Click in the search box and type the letter “a” and press Enter:
As you can see it did not filter as expected. This is because the In Column value is set to All Visible. Since the letter “a” appears somewhere in every breakpoint we need to tell search to only pay attention to the labels column:
This results in getting the desired outcome:
To clear the search criteria just click the Reset Search Criteria button:
All the breakpoints will come back:
You can do many great things with this feature so experiment and see if it is valuable for you. There are a lot of great things you can do with breakpoints and this is only the tip of the iceberg. I’ll discuss other features in a future article.
This is one change to Visual Studio that I’m not a fan of and I still continue to see a ton of posts on this change so thought I would share here as well.
I always try to give credit where credit is due and I believe the earliest mention of this fix is by Richard Banks in his post 6\1\2012 here: http://www.richard-banks.org/2012/06/how-to-prevent-visual-studio-2012-all.html
Okay so you really, really don’t like the Uppercase menu in VS2012 because you feel like it is shouting at you:
You would rather go back to mixed case for your menu:
Not a problem! Below are ways you can fix this feature in VS2013.
WARNING: Making changes to the registry can cause unexpected results so do any changes at your own risk!
NOTE: Watch your spelling if you are typing this manually.
If you like to “simplify” this a bit you can use PowerShell to run a nice script to make this happen. However, if you haven’t used PowerShell before this may not be faster for you.
Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\12.0\General -Name
SuppressUppercaseConversion -Type DWord -Value 1
Restart Visual Studio and you are good to go.
This one is a little known feature you can take advantage of when working with your code. Assuming you have some unformatted code:
You can format the entire document by going to Edit -> Advanced -> Format Document (CTRL+K, CTRL+D) to get this:
You can also do this with just a selection of code:
Go to Edit -> Advanced -> Format Selection (CTRL+K, CTRL+F) to get this:
I won’t go deep into it here but it’s important to remember that the automated formatting follows the default rules you can easily change by going to Tools | Options | Text Editor | [Language] | Formatting in most cases. For example, to change the HTML rules go to Tools | Options | Text Editor | HTML | Formatting:
In the case of HTML, you can go pretty deep into the formatting options by clicking on the Tag Specific Options button:
Formatting the document or selection is a great way to make your code more readable. Enjoy!
NOTE: This is an older feature I’ve updated the information for VS2013
Ever been writing some code and you want to leave a reminder to yourself to do something on a particular line or area? Did you know about the "to do" comment feature or custom tokens? They seriously rock if you have never used them and, because they go in source code, everyone can have access to the information when you check-in the code!
So here's how TODO comments work:
In VB you just put any comment in that begins with the letters "todo" (case doesn't matter):
In C# and C++, it's pretty much the same thing (again, case doesn't matter):
In C++ you have to explicitly turn this feature on. Go to Tools | Options | Text Editor | C/C++ | View and change Enumerate Comment Tasks to True:
Regardless which language you use the result is an entry in your Task List:
Note: You can Double Click any entry to automatically have the editor go to the respective line in your source.
If you don’t see the entries, make sure you have set the task list to see comments:
We actually have several tokens you can use in addition to TODO. To see all the existing tokens go to Tools | Options | Environment | Task List:
You are welcome to use HACK and UNDONE as well. The MSDN documentation is horrifically bad when it comes to describing these tokens and I don’t agree with the description of use necessarily. Here is what it says:
“Items labeled TODO, HACK, and UNDONE in the Task List window indicate code problems that do not keep the project from compiling, but that do cause run-time errors. You should correct these errors before running the project.”
Also, be aware that the number of entries that appear in the Task List changes depending on the type of project you are working on. With VB and C# projects, the Task List displays all of the comments in the project whether the file is open or not. With C++ projects, the Task List displays only the comments that are found in the files currently opened for edit.
Feel free to create your own tokens for your use. Creating your own tokens is very simple, just pick a name for your token and type it in the Name textbox:
Note: UnresolvedMergeConflict looks like an error but isn’t it is an actual token that will make a high priority item in the Task List.
Next choose a priority level:
Then click the Add button to make it an active token:
You will see it in your list:
Now you can use the token in your comments:
Be aware that any tokens you create ARE NOT SHARED with other developers so you may want to come up with a standard set of tokens for everyone to use if you intend to leverage this feature company-wide then export them (http://blogs.msdn.com/b/zainnab/archive/2010/07/14/exporting-your-environment-settings-vstipenv0021.aspx) and have folks import them (http://blogs.msdn.com/b/zainnab/archive/2010/07/15/importing-or-changing-your-environment-settings-vstipenv0022.aspx).
Tokens are a pretty nice feature to keep track of places in your code you need to revisit. I don’t suggest them over, say, tasks in Team Foundation Server but they are a great short-term reminder for things that need to get attention. If you decide you would like to create Task List items programmatically you can do that as well. Here is a link to some guidance to get you started:
The original Code Map was introduced in the product with Visual Studio 2012 Update 1. You need to read my original post before moving on:
My assessment at the time was that it was a good feature but had poor performance and didn’t really add much value relative to Dependency Graphs. With debugger integration however Code Maps have definitely come into their own and the performance is very good.
Note: Code Map Debugger Integration is a feature in the Ultimate edition of Visual Studio.
Assuming you have a handle on Code Maps now let’s see how the debugger integration works. First, I’ll take the TailSpin Toys sample code and set a breakpoint within the code base (ShoppingCart.cs, line 61):
I’ll press F5 and add an item to my cart to trigger the debugger:
Ordinarily, we would step though the code and hope we remember how we got to a particular place. Those days are gone! Now we can turn on the Code Map feature while debugging:
You can also find this on the Menu Bar at Debug | Show Call Stack on Code Map:
If we take a closer look at the current map, we can see that it shows how we arrived at the current call (the squares above the last AddItem call) and our current location (yellow arrow). Although the current location indicator is partially covering it, you can also see the breakpoint indicator:
Stepping through the code we see the map keeps updating so we don’t have to keep the path in our heads:
The Code Map will continue to update for our debugging session showing where we have been and where we currently are in the call stack:
The graphs can get quite large:
For this reason it’s important to use the map tools at your disposal. The context menu items when you Right Click any node are a great example of common tools:
You can Double Click any node to view the code from that location in the stack. A green arrow will indicate your current position:
If you happen to choose a node that isn’t part of the current active call stack then you will get a slightly different indicator:
When you stop debugging the Code Map will be preserved so you can save it if desired and keep a map of the code base you just went through. I think this is an exceptional addition to the debugging experience!