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 + P Menu: File -> PrintCommand: File.PrintVersions: 2008,2010Published: 3/9/2010Code: vstipEnv0006
Want to print your line numbers with your code? Don't worry! You can do it by just checking the "Include line numbers" option in the Print Dialog:
Versions: 2008,2010 Published: 6/7/2010 Code: vstipTool0029
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? It seriously rocks if you have never used it AND, because it goes in the source code, everyone can have access to the information when you do you check-in!
So here's how it works: In VB you just put any comment in that begins with the letters "todo" (case doesn't matter):
In C#, it's pretty much the same thing (again, case doesn't matter):
C++ requires that the “TODO” be in upper-case or it will not show up in the Task List:
In C++ for VS2010 you have to explicitly turn this feature on. Go to Tools | Options | Text Editor | C/C++ | Formatting | Miscellaneous and change Enumerate Comment Tasks to true:
Regardless which language you use the result is a nice entry in your Task List:
NOTE: In order to see these items, you have to click the drop-down list in the Task List and choose Comments as shown here.
[ NOTE: This post has been depricated. The new, updated post can be found here:
UPDATE 3/8/2012: As of the Beta this does not work with all project types. Most notably web projects are not supported currently for this feature. For more information on what is supported and what isn't look here:
Probably one of the most welcome new features in VS11DP is the new project backward compatibility feature also known as project round tripping. Let’s dig into the details.
In all prior incarnations of Visual Studio if you had an older version, VS2008 for example, and opened up the project in a newer version, VS2010 in this case, you had the option to convert the project. If you did the conversion it was a one-way trip. You couldn’t open the project again in VS2008 if you tried to go back. This has been the source of a lot of pain and suffering for developers who have to work with multiple versions of Visual Studio. We want the cool features of the latest IDE but still want others on our team to be able to open the solution in the older version of Visual Studio when they get the files from source control.
You can now create projects in Visual Studio 2010 with Service Pack 1 then open those projects in Visual Studio 11 Developer Preview and THEN open the project up again in VS2010SP1. In other words, we now have full project round-tripping capability so you can work with the latest features but still keep the solution compatible with and older version of Visual Studio.
Here are the steps you can take to test this for yourself:
NOTE: This is an older feature. I’ve updated the information for VS2013.
This is one change to Visual Studio that I’m not a fan of and I still continue to see a ton of posts on this change so thought I would share here as well.
I always try to give credit where credit is due and I believe the earliest mention of this fix is by Richard Banks in his post 6\1\2012 here: http://www.richard-banks.org/2012/06/how-to-prevent-visual-studio-2012-all.html
Okay so you really, really don’t like the Uppercase menu in VS2012 because you feel like it is shouting at you:
You would rather go back to mixed case for your menu:
Not a problem! Below are ways you can fix this feature in VS2013.
WARNING: Making changes to the registry can cause unexpected results so do any changes at your own risk!
NOTE: Watch your spelling if you are typing this manually.
If you like to “simplify” this a bit you can use PowerShell to run a nice script to make this happen. However, if you haven’t used PowerShell before this may not be faster for you.
Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\12.0\General -Name
SuppressUppercaseConversion -Type DWord -Value 1
Restart Visual Studio and you are good to go.
Menu: Tools -> Options -> Text Editor -> All Languages -> General -> DisplayVersions: 2008,2010Published: 3/7/2010Code: vstipEdit0025
Line numbers are not on by default. To turn on line numbers just go to Tools -> Options -> Text Editor -> All Languages -> General -> Display and check Line numbers:
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):
Okay so last quarter I was asked if you can call stored procedures using Language Integrated Query (LINQ). The answer, of course, is YES! It would be kind of silly if we didn't include this type of functionality. :P
NOTE: You need the following items to do this example
SQL Server (pretty much any version will do but this example uses 2005)
Visual Studio 2008 (Beta 2 was used for this example)
A little time to sling some code
So how exactly DO you call a stored proc using LINQ? Easy just follow these simple steps:
[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)
Well! I had an interesting night. As many of probably know by now we have four dogs at my house: Max (Basenji), Fibi (Jack Russell Terrier), Lily aka Piggy (we think she is a Pit Bull mix), and Zorro (Blue Tick mix). With four dogs you are always breaking up little fights between them at one time or another. Not sure if it is just our dogs or this is a normal thing.
Last night my dogs were in the backyard and I heard a little skirmish start. I did my usual yell to tell them to cut it out but this time Zorro kept making a funny noise like he was hurt. It didn't sound good at all. I went out side and found Max and Zorro attacking Lilly. Normally Lilly can handle herself no problem but she didn't seem to be fighting and it looked like Zorro had her around the neck.
As I approached and got Zorro to hold still I discovered that he had managed to get his lower jaw stuck in Lilly's collar. As I looked closer I found I was having a hard time getting Zorro lose so I brought them closer into the light near our porch. That is when I realized there was a bad problem. Zorro was really stuck and there was blood all over Lilly.
I called for my wife to come down and give me some help and she began looking for a flashlight to get a better idea of what we were dealing with. Right after she left, I noticed that Lilly had a funny look and realized she was choking--things were much worse than I thought. OMG. I almost freaked but held it together and called for my wife to bring me a knife (screw the collar, ill buy a new one). It was close but I managed to cut the collar off w/o cutting Zorro or Lilly. As soon as I cut them lose, I grabbed Lilly who had turned purple and had stopped breathing.
I didn't know you could give a dog mouth-to-mouth but my wife (freaking out) managed to say "give her mouth-to-mouth". Now, I have to admit, giving my dog mouth-to-mouth was not appealing to me but when you are faced with a purple dog you tend to not give a crap. I directed her to start the car so we could take Lilly to the emergency room and gave the the dog mouth-to-mouth.
It worked! I never, EVER would have thought you could resuscitate a dog that way but she started breathing slowly and we rushed her to the emergency room. By the time we got to the emergency room, she had completely restored breathing and was just a regular dog. So there we were in our pajamas with a perfectly healthy dog just wagging it's tail and having a good time. About 30 minutes and 95 dollars later we were on our way home and now we are looking for a new (hopefully safer) collar for Lilly. :P
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.