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).
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. :)
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:
Keyboard: CTRL + SHIFT + F Menu: Edit -> Find and Replace -> Find in FilesCommand: Edit.FindinFilesVersions: 2008,2010Published: 1/3/2010Code: vstipFind0002
You can customize your Find in Files results to show what you want to see and how you want to see it.
Example: You don't want to view the entire file path shown in the Find Results tool window.
So instead of this:
You want this:
No problem! :)
DANGER: This involves hacking the Registry so use this tip at your own risk!
Here are valid values you can use in the string:
$v drive/unc share
$x end col if on first line, else end of first line
$L span end line
$C span end col
$0 matched text
$t text of first line
$s summary of hit
$T text of spanned lines
[EDIT: As Guy pointed out on his blog http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/11/19/visual-studio-2008-rtm-is-available-for-msdn-subscribers.aspx VS2008 is RTM for MSDN already]
By now it is no secret that Visual Studio 2008 will RTM before the end of November. Soma mentioned this at TechEd Europe and I couldn't be more excited! Make sure you are getting ready with for the new version by checking out our webcasts and other training materials that are available. Here is a list of places to help you get prepared:
Main Visual Studio 2008 Product Page http://msdn2.microsoft.com/en-us/vstudio/products/default.aspx
Main World Wide Events Website http://msevents.microsoft.com/cui/default.aspx?culture=en-US
NOTE: Don't let the name throw you off, this is your best "one stop shop" for getting MS content. Make sure to take advantage of the Virtual Labs! Below is an extremely short list at what I found when I searched on the keyword "linq":
Channel 9 (of course) http://channel9.msdn.com/
And of course the various blogs (on the left hand side) and other resources that crop up. I will be doing a 26 part webcast on new features of VS2008 beginning in December as well.
In the meantime, let's have a contest. Post here with your list of resources for getting up to speed with VS2008. I will randomly choose one person to be the recipient of ONE of these prizes (winner's choice):
Windows Vista Ultimate
Office 2007 Ultimate
Halo 3/Flight Simulator X Combo gift
[Edit: contest extended until 12/1 by popular demand!]
Just in time for the holidays! Contest ends on 11/26/2007 @ 5pm Central. Good Times :)
(MS employees not eligible but shoot me an email if you would like to see an FTE version of this contest)
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 -> Projects and Solutions –> General Commands: View.TrackActivityinSolutionExplorer Versions: 2005,2008, 2010 Published: 3/29/2010 Code: vstipProj0011
Note: Several people have asked if you can turn this feature on and off at will. You can if you bind the View.TrackActivityinSolutionExplorer command to a keyboard shortcut.
By default, VS2010 will track the current file you are editing in Solution Explorer. It looks like this:
Notice that the current file being edited is also selected in Solution Explorer automatically. This is a great way to keep track of where you are in the solution when you are working with a lot of files. You can turn it off if you want. Just go to Tools -> Options -> Projects and Solutions -> General -> "Track Active Item in Solution Explorer" and uncheck the option to turn this feature off.
Menu: Project -> Add New Solution Folder; [Right-Click Solution] -> Add -> New Solution Folder Command: Project.AddNewSolutionFolderVersions: 2008,2010Published: 3/27/2010 Code: vstipProj0009
Did you know there are special folders to help you organize large solutions? There is! They are called, appropriately enough, Solution Folders. To create one just Right-Click on your solution (or go to Project -> Add New Solution Folder) and you will see this in Solution Explorer:
Simply give the folder a name and you are good to go. But so what? I mean, what can you actually DO with these things? Here is a list of stuff you can do:
Move or add projects to them. Solution Folders can be nested to create greater organizational structure.
Add, delete, or rename Solution Folders at any time, if the organizational requirements of the solution change.
Unload all projects in a Solution Folder to make them temporarily unavailable for building.
Collapse or hide entire Solution Folders so that you can work more easily in Solution Explorer. Hidden projects are built when you build the solution.
Build or rebuild all the projects. The projects are built in the order specified by the project dependencies.
Solution Folders are an organizational tool in Solution Explorer; corresponding Windows folders are not created. Microsoft recommends that you organize your projects on disk in the same way that you organize them in the solution. But that is your call :)
Shoot me the URL to your blog and point out where you have linked to me. I will pick one lucky victim...er...winner to reward with a Visual Studio 2008 Backpack or 3 Visual Studio T-Shirts.
This post is a bit overdue but better late than never. So let’s talk about Visual Studio Update 1…
Soma originally introduced Update 1 in his November 26th post here:
Since some of you may want to install this update immediately there are a few options for you.
From inside the IDE, go to Tools | Extensions and Updates:
Then look under the updates section and install from there:
If you want a more direct route you can click this link: http://go.microsoft.com/?linkid=9821199
You will get this dialog and can just click Run to execute the small .EXE and begin the online install:
Although many believe you can only install via online resources this is actually not true. A quick look at vsupdate_KB2707250.exe /? shows us the /layout switch:
So when I run vsupdate_KB2707250.exe /layout c:\ziptemp\vsup1 on my system this is the dialog I get:
This will download the source files to the designated location so you can make them available on a network share, thumb drive, or other media for stand-alone installation.
The most obvious question is, “Why should I care?” Despite the bug fixes and new features, this particular update represents a major shift in the timing for delivery. We have now committed to a shorter update cycle so we can deliver critical fixes and incorporate new features more quickly. What this means for you in real terms is that blocking issues may be resolved much more quickly and/or you will get a new feature that will help you get work done better/faster/stronger.
So what exactly did we deliver? Fundamentally there were two things we provided: Bug Fixes and New Features. You can find all the details here:
I’m going to repeat the bug fixes here and then address the new features in another article right after this one.
After an extended period of time looking for the list of bug fixes included in the package I was initially unable to find a comprehensive list anywhere. It looks like the team recognized there was a gap and updated the KB article on 1/13 to include all the relevant information. I’ll just repeat the information here verbatim for convenience.
I love the title of this one because I’m sure someone will read this and wonder why I think Solution Explorer is a “new” feature. I mean, haven’t we had this sucker for a billion years? Aren’t there cave drawings in France about this feature? So why is it “new”? Let me show you!
First and foremost, you can now search Solution Explorer! I’ve been wanting a feature like this since before Solution Explorer was even invented back in my VB 3 days (about 19 years ago). Here is what things looked like back then:
And from then until Visual Studio 2010 we STILL couldn’t search items:
But now you can! Just type in any search term into the Search Solution Explorer textbox:
And it will find anything that contains the search term in it:
You can filter the search to choose how broad the search goes by clicking on the drop down arrow to the far right of the Search Solution Explorer textbox:
(NOTE: searching within file contents doesn’t mean what you think it means. See the section “More Than Physical” for information)
One other cool feature is you can have Solution Explorer only show you the currently open files by clicking the drop down button just to the right of the Home button:
In the past, Solution Explorer was relegated to only showing physical elements or those things that help contain / organize those elements (i.e. solution folders). That’s out the window, too. Now the experience doesn’t stop at the physical level but extends to logical elements as well:
Which makes searching even more awesome:
If you are using the Preview Tab then clicking on any item in Solution Explorer will go to the file and highlight code if applicable BUT you can’t double click the logical item to open the file for some reason and instead have to double click the filename to open it.
Navigation is much improved as well.
After a doing a search, like the one shown above, you can click the Home button:
And Solution Explorer will go back to “normal”:
Clicking the Back button:
Takes me back to the search I just did:
Here is the weird part: If I reuse the search box and type another search right away it doesn’t remember the previous search I did and I can’t go back; BUT if I click Home between searches then it remembers all my old searches. I’ve tested this up to 12 entries and it works fine as long as you remember to click Home between searches.
Occasionally you may be looking at a file but Solution Explorer isn’t on that file. When this happens a button appears that allows you to sync Solution Explorer with the document you are currently in so you can see where it is in the project structure.
The right click experience is, to say the least, incredible! Depending on what you select the context menu changes appropriately. So if I right click a code file this is what I get:
But if I right click a class this is what I get:
And this is the context menu for a method:
Each option changes the view in Solution Explorer to better examine relationships. The bottom line: make sure to check out your context menus to change the elements you are viewing in Solution Explorer.
There used to be a button for creating a new instance of Solution Explorer which was excellent for multi-monitor viewing of code:
The button is gone now (which is a mistake in my opinion) and you can no longer get an entire copy of Solution Explorer in a new window BUT you can get a copy of any project or file in a new Solution Explorer window which is what I have done in the example above. Just right click any project/file and choose New Solution Explorer View:
If you are using TFS then you can filter Solution Explorer to show you files with Pending Changes:
And there you have it! As you can see there are quite a few changes in the new, improved Solution Explorer so go explore!