It’s nice to see Microsoft adopting features other IDEs have had for years.
Borland’s Delphi has had it for years via the CodeRush add-in. It will be standard in Delphi 2006 (Borland Developer Studio). Borland calls it Live Templates.
I am sure when Microsoft finally delivers a live two-way modeling tool and object persistent framework, we’ll hear praise of how ingenious they are. In the meantime, I can continuing using Delphi and get those features /now/.
So finally, it’s able to do the same I’m used to Eclipse for years (and was wondering, why it doesn’t exist in Visual Studio .NET 2003).
It’s nice but I never learned the shortcuts for complete blocks of code (like ‘svm’ for static void main).
Also useful (and I assume it exist in VS .NET 2005 as well) is the ability to comment out selected lines with pressing CTRL-SHIFT-7) and uncommenting it again with pressing the same combination.
I first encountered snippets in Homesite. I’m glad to see that VS.NET has joined the ranks of editors I would consider using.
I don’t think I’ve ever thought to share my snippets with anyone, though. To me, code snippets are very personal. They’re tuned to what my brain thinks is a block of recurring code. The shortcuts are easy to remember because I thunk 'em up myself.
A better place to put your own snippets is in the folder provided in your My Documents\Visual Studio 2005\Code Snippets folder. It will save you time when you want to export them. Although, if you edit the ones provided by VS, you’d have to move them too, if you want to keep them.
I really like the surround with for XML files. I’m always forgetting elements and the surround with makes it way easier.
btw, there is a shortcut key (Shift+Alt+F10) to include using statements for assemblies. A smart tag shows up at the end of the class name too, if the IDE can find the class.
I’ve been using Code Snippets via Resharper, so I’m looking forward to this being built in.
For example, I created a “Property” snippet so that when you name the private member “_someMember”, it automatically names the property “SomeMember”. (I noticed you’re an underscorer too). Just a bit less typing than the demo you showed.
I was experimenting with that when renaming variables, I didn’t realize it worked for adding assembly refs as well. I wonder why they made it such a contortion-inducing shortcut chord… not exactly easy to press.
This also works in VB.NET, but it changes the ref to “Net.WebClient” instead of an “Imports System.Net” statement … weird.
Another one of the great features MS Visual FoxPro had for years. Remember to thank YAG and his team for showing the VS.Net interface guys how to do things right in VS.Net 2005.