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 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.
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:
Menu: Tools -> Options -> Environment -> AutoRecoverVersions: 2008,2010,2012,2013Published: 6/30/2010Code: vstipEnv0019
WARNING: Read the comments associated with this post as there are multiple complaints that this features doesn't work as expected. Read this thread from the engineering folks about usage with versions VS2010 and older.
Perhaps your best friend is the AutoRecover feature. It can be a real life saver if the dev environment crashes or there is a power outage or a meteor hits your cube (okay, maybe not that last one). It's very simple to use, just go to Tools -> Options -> Environment -> AutoRecover:
If you want to turn this feature off you can deselect the "Save AutoRecover information every" checkbox. Of course, if you do this we will all laugh at you when you lose important work because you didn't have it and I will personally blog about it so everyone knows--you might want to leave it on--just saying. Here is what the other options do:
X minutes - determines how often files have AutoRecover information saved. The default is 5 minutes but you can adjust up or down depending on usage. There is an inverse relationship between this value and the frequency of your updates to code. If you make more frequent updates to code then have a lower number here. Fewer updates to code mean you can increase this number if you desire. If you are going to make a mistake here make it on the side of a number that is too low rather than too high. It's better to take any performance hit from file I/O than to lose a ton of work.
X days - used to decide how long AutoRecover files are kept in the Backup Files directory. The default is 7 days which is usually adequate for most situations. If you work with a lot of projects over a short period of time then you may want to decrease this number to keep the Backup Files directory more clear. If you are going to guess on this value then it's better to guess high and lower the number as needed.
Let's be clear on what a is exactly saved and where it is saved. First, recovered files are stored at \...\My Documents\Visual Studio <version>\Backup Files\<projectname>. Not every file is saved here. Let me show you an example:
Here is the backup folder for one of my solutions when I create it in Visual Studio:
Obviously the folder is empty. Now let me make a change to a file and save the change. Then I'll wait 5 minutes to see the result:
Still nothing because there is no need to recover a saved file. But let me make a change to a file without saving it and wait another 5 minutes:
NOW we have AutoRecover information because if there is crash we will have to make a decision to recover the unsaved changes or keep the last saved version. This is essentially the function of AutoRecover.
When you do finally have to recover a file, this is the dialog you will get:
Recovered files - lists the file(s) that can be recovered with a a checkbox to select/deselect the file as well as basic information.
<File Name> Summary - shows detailed information about the currently selected file including date/time info, location of the backup file, and destination location where the file will be recovered to.
Recover Selected Files - performs a recovery action on the file(s) selected copying the recovered source file to the previously indicated destination.
Do Not Recover - closes the dialog box without recovering any of the files listed.
Menu: Edit -> Advanced -> Tabify Selected Lines; Edit -> Advanced -> Untabify Selected Lines Command: Edit.TabifySelectedLines; Edit.UntabifySelectedLines;Edit.ConvertTabsToSpaces;Edit.ConvertSpacesToTabs Versions: 2008,2010Published: 3/14/2010Code: vstipEdit0028
Some people prefer spaces, others prefer tabs. Well you can have it any way you want it with this next item. You can convert spaces to tabs and convert tabs to spaces on your selected lines. There are a couple of ways to do this and each has different results:
Tabify / Untabify
If all you want to do is convert leading spaces to tabs (or vice versa) then you would use the Tabify/Untabify commands. First, start out with a line with some leading spaces (NOTE: You don't have to select the entire line for this to work as long as any part of the line is selected it will perform the action):
Now go to Edit -> Advanced -> Tabify Selected Lines:
And you should get the leading spaces converted to tabs:
Obviously, to change leading tabs to spaces you would use Untabify Selected Lines:
ConvertSpacesToTabs / ConvertTabsToSpaces
Okay, so what if you want ALL spaces to tabs? Well you have to use a command to do that and will have to make a custom keyboard mapping. The commands you are interested in are Edit.ConvertTabsToSpaces and Edit.ConvertSpacesToTabs. Here is what ConvertSpacesToTabs does to our example (NOTE: For these commands you have to select everywhere you want to convert it will not automatically convert the entire line in case you just want to convert a part of the line):
As you can see, almost all spaces are converted to tabs. Since spaces are converted to tabs in increments of 4, if you have, say, 6 spaces it will result in a tab and 2 spaces left over. That is why there are some left over spaces in the example. And, naturally, if we select these lines and run ConvertTabsToSpaces this will be the result:
And now you know how to convert tabs to spaces and spaces to tabs. Have fun!
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:
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.
Keyboard: CTRL + -; CTRL + SHIFT + - Menu: View -> Navigate Backward; View -> Navigate Forward Command: View.NavigateBackward; View.NavigateForward Versions: 2008,2010Published: 3/1/2010 Code: vstipEdit0024
The editor remembers locations when you move in a single command more than several lines away from where you are currently working, or if you edit in a particular location that is not adjacent to the last place you edited.
The goal is to remember interesting locations so that you can recall where you have been working without remembering so many locations the feature is not useful (such as every character typed, or every line entering several new lines of code one right after the other).
A go-back marker is dropped under the following conditions:
An incremental search (including reverse) leaves a go-back marker at the beginning of the search and another one at the end.
A Go To Line action, like CTRL + G, or a mouse-click that moves the cursor 11 lines or more from the current position drops a go-back marker at the new location.
A destructive action (like hitting Backspace) after having moved the cursor to a new location drops a go-back marker.
Doing a search, like Ctrl+F, drops a go-back marker at the found location.
Opening a file drops a go-back marker wherever the cursor was on the old file and drops another on the opened file.
So with all that, welcome back to the wonderful world of the Navigate buttons (and keyboard shortcuts, too)! These gems make travelling around your code much, much easier:
Menu: Tools -> Options -> Projects and Solutions -> General Versions: 2008,2010Published: 3/26/2010 Code: vstipProj0008
If you don't like seeing the solution file in Solution Explorer, you can easily hide it (or show it if you have it hidden). First, let's review what the default looks like with the solution file showing:
Now if we go to Tools -> Options -> Projects and Solutions -> General and uncheck "Always show solution":
This is the result:
SPECIAL NOTE: This only works when there is one project in the solution. If you have multiple projects in your solution it will ignore this setting and give you the default view.
If you haven't come across this yet you will at some point. There is a known issue with Vista and activation. You can get the details for common errors at this KB article, but the steps are pretty straightforward:
1) Go to Control Panel...System and Maintainence...System
2) Scroll to the bottom of the screen
3) Click on Change Product Key
4) Type in your key
5) Click Next and follow the rest of the steps in the wizard
That's it! Soon you'll be enjoying Vista and be activated :)
Several people have asked me how to convert from VMWare to VHD format. Here are the steps to get you going:
1) Download VMDK to VHD converter free tool from http://vmtoolkit.com/files/folders/converters/entry8.aspx I had successfully converted disks 29Gb in size
2) “Prepare” your VMWare image by following steps in http://searchservervirtualization.techtarget.com/tip/0,289483,sid94_gci1239063,00.html or http://www.jaylee.org/post/2008/10/How-to-convert-a-big-VMWare-VMDK-into-an-Hyper-V-VHD.aspx
3) Install Virtual Server 2005 (Std/Ent, R2 or not – but if R2, select Enterprise and install the one with SP1 – it’s all free and on the web…)
4) Make sure your VMWare image contains at least one IDE drive before final shutdown (VS2005 will need it). Take note of drives inside VM (C,D,E…)
5) Convert each one VMW files into VHD
6) Attach “system” disk as a main disk in new Virtual Server image
NOTE: You could roll out Virtual Machine Manager and use the “conversion” feature in one step instead of six.
Thanks to Oleg Kofman from MS who provided me this info...