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 + K, CTRL + K (toggle bookmark)Menu: Edit -> Bookmarks -> Toggle BookmarkCommand: Edit.ToggleBookmarkVersions: 2008,2010Published: 7/5/2010Code: vstipTool0047
Bookmarks are a pretty cool feature that a lot of people don't seem to know about. Essentially, Bookmarks are a way to mark locations in your code. Unlike tokens ("TODO's"), Bookmarks are not stored with the source code. There are numerous ways to set a Bookmark. The simplest way is to use CTRL + K, CTRL + K to create a single Bookmark:
When you set a Bookmark it will create a glyph in the Margin and create an entry in the Bookmarks Window:
The good news is you don't have to keep the default name that is given for the Bookmark. Just RIGHT CLICK the entry in the window and choose "Rename":
Then put in whatever you want for the name and you are good to go:
You can continue to use this method or the menu to create Bookmarks. Another cool way to create Bookmarks is to use the "Bookmark All" (bottom right) button in the Quick Find dialog (CTRL + F):
We all explore code and need to move quickly between files when examining code to get familiar with it or debugging or [insert file browsing scenario here]. In prior versions of Visual Studio you had to open a file to look at the contents which often resulted in many open files (tabs) when you were done. The Preview Tab eliminates the need to open files when browsing code. Most likely you’ll first encounter the Preview Tab when you are looking at files with Solution Explorer. When you click on a supported file type, you will see the contents of that file in the new preview tab (to the far right in the tab well):
If you click anywhere inside the file the tab will go from grey to purple to distinguish it from regular (blue) tabs:
Again, the point of the preview tab is to let you view the contents of a file without actually opening up a new tab in the tab well. As you look at different files the preview tab only shows the contents of the file you are currently on. This keeps the environment from getting cluttered with open tabs and allows you to focus on only those files that are interesting to you. Solution Explorer isn’t the only place you can use the preview feature. It turns up in several situations where you might need to look at file content. For example, when using Find in Files (CTRL + SHIFT + F) to locate information you will see the preview tab:
At some point you may decide to promote the preview to an opened tab in the Tab Well so you can do additional work on the file or just keep it around for other purposes. There are a few ways you can make this happen.
Probably the least useful and and least likely technique you will use is to click on the tiny Keep Open button on the Preview Tab. It’s not only useless it’s actually kind of annoying for some reason I can’t identify:
The most likely approach is you will just double click the file in Solution Explorer or whatever results dialog you happen to be in.
With the cursor inside the file (the tab is purple), just press CTRL + ALT + HOME to open a tab for the file you are currently viewing.
While previewing a file, if you make any change to the file it will automatically be promoted to an open tab so that you can make additional changes and do any other actions you need to perform.
Another button is useless and a waste of space on the Solution Explorer toolbar is the Preview Selected Items button. You can click it to preview the current file and its only use that I can find is if you turn off single clicking a file to preview it (see below). Also the tooltip would lead you to believe that you can select multiple files and preview them. Nope. Doesn’t work. Don’t waste your time with this button.
To see the options you have for using the preview feature, just type preview in Quick Launch (CTRL + Q) and click Environment -> Tabs and Windows:
This will take you to Tools | Options | Environment | Tabs and Windows:
To turn off the preview feature (NOT suggested unless you are having performance issues with it) uncheck the Allow New Files to be Opened in the Preview Tab option. Also notice you can decide if a single click open the files in for preview in Solution Explorer and Find dialogs. For Solution Explorer you can use ALT to prevent a file from being previewed when you click on it. While I see the value in using ALT to prevent preview from happening. I haven’t yet found any reason for turning off the single-click option as it, in effect, forces you to use the Preview Selected Items button which is a lot of extra work and kind of defeats the purpose of the feature.
The Preview Tab is one of my top two favorite features in Visual Studio 2012 (the other one being project round-tripping). You definitely want to leverage this feature to make your life easier.
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:
[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.
NOTE: This is an older feature. I’ve updated the information for VS2013.
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!
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.