Create New Code Snippets from Existing Ones


Versions:  2008,2010
Published:  4/24/2010
Code:  vstipTool0016

 

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

 

One of the things you will want to do when you use snippets is change the default values.  Naturally, you can modify the values once the snippet is used:

image

 

BUT what if you want to permanently change the value and make a new snippet out of it?  I'm going to show  you how!

 

First, figure out what snippet you want to modify by finding it in the Code Snippets Manager.  In this case, let's modify the "If..End If" snippet for Visual Basic:

image

 

What we are after is the location of the snippet.  See the path under Location?  Select it with your mouse and copy it:

image

 

Now, go to File -> Open -> File:

image

 

Paste in the file path and click "Open":

image

 

This next part is really just to make sure we don't mess up the original snippet.  As you gain more experience doing modifications you may choose to change the original but, for now, we are going to make sure you can keep your existing set of snippets intact.  Go to File -> Save As:

image

 

Just save the file with the original file name and your initials appended to the end:

image

 

Okay now we are ready to modify the snippet.  Let's start with the header information:

image

 

For now, just change the Title and Shortcut to include your initials like this:

image

image

 

Since you are here to change the default value as well, locate the Default tag:

image

 

Change "True" to "False" then save the file and close it. 

 

You are now ready to use your new snippet.  Go into your code:

image

 

Type in your new snippet shortcut and hit TAB (once or twice, both work the same):

image

 

And you get the result:

image

 

Congratulations!  You now have a new awesome snippet you can use.  You can verify this by going back into the Code Snippets Manager (CTRL + K, CTRL + B) and finding your snippet:

image

Comments (0)

Skip to main content