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).
Menu: Tools -> Options -> Text Editor -> All Languages [or specific language] -> General -> Statement completionVersions: 2008,2010Published: 5/1/2010Code: vstipEdit0054
So maybe IntelliSense isn't for everyone. It can sometimes annoy people when it automatically pops up. You can disable automatic IntelliSense and still have it come up anytime you want with CTRL + J.
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.
Windows: ALT + W, N (new window); ALT + W, V (new vertical tab group)
Menu: Window | New Window; Window | New Vertical Tab Group
Command: Window.NewWindow; Window.NewVerticalTabGroup
Versions: 2005, 2008, 2010
For quite some time you have been able to split your code windows horizontally (see http://blogs.msdn.com/b/zainnab/archive/2010/03/05/split-your-windows-vstipenv0004.aspx) but did you know there is a technique you can use to split your code windows vertically?
These techniques do not work on .ASPX files see http://blogs.msdn.com/b/zainnab/archive/2010/12/05/vertical-split-view-vstipedit0081.aspx
Also, these techniques will not work for .XAML files. To split them vertically click the Vertical Split button in the designer:
First, locate the tab for the file you want to split vertically:
Next, make a copy of the window by going to Window | New Window on your Menu Bar:
Finally, go to Window | New Vertical Tab Group to split the copies:
Now you have the code window split vertically in the IDE. Of course you could always rip one of the copies outside the IDE and vertically arrange them as well (http://blogs.msdn.com/b/zainnab/archive/2010/01/15/free-your-document-windows.aspx).
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.
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: 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!
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.
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:
Keyboard: CTRL + G Menu: Edit -> Go ToCommand: Edit.GoToVersions: 2008,2010Published: 3/8/2010Code: vstipEdit0026
You can go to any line number in your code by simply pressing CTRL + G. You will get this dialog:
Just type in your desired line number and click OK. The Cursor will move to the line number you typed.