April 24, 2019
Hot Topics:

Using Code Snippets in Visual Studio 2005

  • May 16, 2005
  • By Paul Kimmel
  • Send Email »
  • More Articles »

Insert Snippets

After you have created the .snippet file and copied it to the My Code Snippets folder, you can use the snippet to generate code. To insert the snippet, select Edit|Intellisense|Insert Snippet, navigate through the list of snippets—which are organized just as they are in the file system—and select the snippet (see Figure 2).

Click here for a larger image.

Figure 2: Ctrl K+Ctrl X Display the List of Snippets

After inserting the snippet, code elements that were marked as replaceable will be highlighted (see Figure 3). Replace the highlighted elements with the actual value. For example, if you want the Customer collection in Figure 3, you can leave the code as is. Otherwise, replace all of the highlighted instances of Customer with the type you will be collecting.

Click here for a larger image.

Figure 3: Replaceable Elements Are Highlighted

Snippets Have Come a Long Way

When you follow the examples in this article, keep in mind that VS 2005 is still in beta. Using beta software can be frustrating, but it can also be a lot of fun. Be patient.

In any case, I hope you got a sense of how far code snippets have evolved from simply copying and pasting text in the toolbox. They now offer manageable, shareable code with replaceable elements, assembly references, and imports statements. I'd say that makes for more than a simple a drag-and-drop article.

About the Author

Paul Kimmel is the VB Today columnist for www.codeguru.com and has written several books on object-oriented programming and .NET. Check out his upcoming book UML DeMystified from McGraw-Hill/Osborne (Spring 2005) and Expert One-on-One Visual Studio 2005 from Wrox (Fall 2005). Paul is also the founder and chief architect for Software Conceptions, Inc, founded 1990. He is available to help design and build software worldwide. You may contact him for consulting opportunities or technology questions at pkimmel@softconcepts.com.

If you are interested in joining, sponsoring a meeting, or posting a job, check out www.glugnet.org, the Web page of the Greater Lansing area Users Group for .NET.

Copyright © 2005 by Paul T. Kimmel. All Rights Reserved.

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date