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).
Keyboard: CTRL + M, CTRL + M Menu: Edit -> Outlining -> Toggle Outlining Expansion Command: Edit.ToggleOutliningExpansion Versions: 2008,2010Published: 3/15/2010Code: vstipEdit0029
By default, Outlining is enabled in Visual Studio. It's the line you see with the boxes to indicate the status of the area (collapsed or expanded):
You can collapse areas of code to get them out of your way so you can focus on other areas. There are four ways to do it:
Once collapsed, the code area will look like this:
Menu: Tools -> Options -> Text Editor -> GeneralVersions: 2008,2010Published: 4/14/2010Code: vstipEdit0048
Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!
To use this feature you need to have "Track Changes" and "Selection Margin" checked.
Okay, so ever wonder how those colors to the left of your code actually work?
Let's begin with a clean slate. Notice there are no colors:
Now let me add a couple of lines of code:
So, all new code will turn yellow to show you what part of the document is "dirty" (unsaved). If we save the code then we get this:
The "clean" (saved) indicator will remain as long as you have the file open. When you close and reopen the file, this is what you get:
New in VS2010: There is now an orange indicator that is used to show a change that is different from the saved version. This was added for the scenario where a user does an undo after a save operation:
Here is a grid to help keep the scenarios straight:
Very cool stuff!
Visual Studio 2013 has another great new feature: enhanced scroll bar functionality. The new scroll bar will show cursor location, breakpoints, and much more! Let’s take a look.
Before we begin I want to address where some of the new features in VS2013 are coming from. In Visual Studio 2013 many of the new features we put into the product were actually introduced via the Productivity Power Tools for Visual Studio 2012. This is an ongoing trend and you will see that many of the new features from future versions will come directly from the Power Tools. If you are still on 2012 you can get a lot of the newest functionality by installing the Visual Studio 2012 Power Tools which can be found here:
To really get a handle on the new scroll bar functionality the first thing you should do is Right Click on the vertical scroll bar and choose Scroll Bar Options:
You will see several settings that can be modified:
(NOTE: You can also get to this area by going to Tools | Options | Text Editor | All Languages | Scroll Bars)
The first two options are pretty self-explanatory they will allow you to show or hide the scroll bars. For the most part you will leave these checked unless you have some special reason not to have them visible.
The Display area allows you to turn on annotations that will show special items throughout the entire document within the scroll bar. This allows you, at a glance, to see where things like breakpoints and bookmarks are. We will look at these in the order you are most likely to encounter them but here is an example of the vertical scroll bar with annotations in it:
The first annotation you will most likely encounter is the caret position indicator. It simply shows the current position of the cursor with a blue line in the scroll bar.
If you missed my blog post a couple of years ago on tracking changes in the editor, this is a good time to read it. You can find the post here:
The Show Changes option simply shows the changes within it so you can see modifications at a glance for the entire document.
This options is fairly broad and covers several types of marks that can appear in code. Most notably this will show breakpoints:
Additionally, this will also show things like Bookmarks:
The final indicator is arguably one of the most important. It shows any syntax errors the editor is aware of:
This let’s you quickly see where there are errors that need to be fixed before you compile your code.
There are two behavior options for the vertical scroll bar: bar mode and map mode. So far everything we have seen is the traditional bar mode for the scroll bar. Now we will switch to map mode:
Map mode essentially turns your vertical scroll bar from this:
Map mode is miniature look at your document so you can quickly get a feel for your code. There are four options for source overview when using map mode. I’ll show examples of the four views below. Of these the Off setting will be the most confusing until you see the Preview Tooltip in action so be patient.
Regardless of which map mode view you use there is also an option to have the Preview Tooltip. Simply put your mouse pointer over any part of the vertical scroll bar and you will get a preview of the code at that position in the document:
All annotations previously mentioned also show up in map mode:
You basically have two options when you want to go to a specific location on the scroll bar. Let’s examine both ways.
As long as you are in map mode:
You can simply LEFT CLICK any area on the scroll bar and you will jump to that location:
For this reason, I suggest, even if you don’t want the map, that you at least use map mode set to Off to get this functionality so you can quickly move around using the scroll bar:
Now that you have a solid base level of knowledge for this feature there is one more important item I want to show you: Scroll Here. If you find any place that is interesting to you in the vertical scroll bar and want to quickly go to that location you can simply Right Click the location and choose Scroll Here:
The new location will come into view so you can begin looking at the code:
The enhanced vertical scroll bar is a great tool for developers to quickly see places of interest and to examine those locations. Try this feature out and see if you like it as much as I do. :)
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!
Keyboard: CTRL + R, CTRL + WMenu: Edit -> Advanced -> View White SpaceCommand: Edit.ViewWhiteSpaceVersions: 2008,2010Published: 4/9/2010Code: vstipEdit0043
I've hijacked today's tip to remind everyone that next Monday I will start giving away $100 ThinkGeek gift certificates (one every day for about 30 days). For details of my evil plan, go here. Also, make sure to sign up for a Visual Studio Launch event in your area. Happy coding!
Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!
Ever want to see the white space you are working with? Maybe you want to know if your spaces are tabs or you have extra spaces on lines. It's easy to view white space. Just go to Edit -> Advanced -> View White Space (CTRL + R, CTRL + W) to go from this:
Keyboard: CTRL + K, CTRL + H [toggles the shortcut on or off]Menu: Edit -> Bookmarks -> Add Task List ShortcutCommand: Edit.ToggleTaskListShortcutVersions: 2008,2010Published: 6/8/2010Code: vstipTool0030
You can create shortcuts to lines of code that you want to revisit later. It's easy! Just go to any line of code then press CTRL + K, CTRL + H (toggles the shortcut on or off). This will create the shortcut glyph in the Margin like this:
To see all your shortcuts, go to the Task List (CTRL + \, T) and choose "Shortcuts" from the drop-down list:
Now you should see all your shortcuts:
You can now treat them like any other task and set priority levels as well as mark them complete:
NOTE: You can RIGHT CLICK any task and choose "Delete" to remove it from the list.
Wanted to get your input on this one. I'm working on the new Tips and Tricks book and had a concept for how I want to show the information. The format is basically the same it is now except heavier use of graphics so instead of SHIFT + ALT + [UP or DOWN ARROW] I use pictures instead. I'm also going to include keyboard mappings if they are different than the default and add mouse commands. There will also be some graphic to represent the version(s) supported and, finally, a list of related tips. This is a VERY rough draft but wanted to get folks engaged early on to get your thoughts.
Here is the prototype tip that I was thinking of:
Zero-length box selection
Related Tips: vstipEdit0006, vstipEdit0007, vstipEdit0008
Let's assume that you have a situation with some variables like the ones below and you want to make them all public:
The answer is a zero-length box selection. Hold down your ALT key and Left Mouse Button, then drag straight down. Note the line that is created:
Release the ALT key and the Left Mouse Button. Now, just start typing:
Bask in the wonder and glory that is the zero-length box selection! :)
Keyboard: CTRL + ALT + I Menu: Debug -> Windows -> Immediate Command: Debug.Immediate Versions: 2008,2010 Published: 9/28/2010 Code: vstipTool0095
When using with the Immediate Window, you can work with class and object members directly:
You can use any method or property as long as it is in context. So, for example, when you are in debug mode, you can call any method that is in scope:
A less-known feature is you can work with properties and methods while in design mode. If you have static methods on a class, for example, you can just execute them right away:
For object members, obviously, you need to create an instance of the object before working with the members:
WARNING: When working with members at design-time a build will occur. This could have unintended consequences so make sure you have experimented with this feature a bit before you use it.
Really nice article Agile meets Waterfall. It's technology is Java but easily translated to our world:
The last one! This series is DONE! Keep an eye out for more my next series in a month or so.
Wecast is here and files are attached.