Using Code Snippets

Keyboard:  CTRL + K, CTRL + X
Menu:  Edit -> IntelliSense -> Insert Snippet
Command:  Edit.InsertSnippet
Versions:  2008,2010
Published:  4/22/2010
Code:  vstipEdit0053

 

Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!

 

I thought it would be instructive to demonstrate how to use snippets.  So, let's say you are in an ASP.NET application and you start to type an anchor tag:

image

 

And you hit TAB twice to get this:

image

 

Snippets have special areas that you can change the values in by hitting TAB to cycle through them.  For example, this snippet has two special areas with the first one highlighted.  I'll put in a URL:

image

 

Then hit TAB to go to the next area and type in some text:

image

 

I can keep hitting TAB to go between these two locations as much as I want.  When I am done I can press ENTER and continue typing more code:

image

 

So, in a nutshell, that's how to work with snippets.  They take a little getting used to but are great timesavers.