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:
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:
What we are after is the location of the snippet. See the path under Location? Select it with your mouse and copy it:
Now, go to File -> Open -> File:
Paste in the file path and click "Open":
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:
Just save the file with the original file name and your initials appended to the end:
Okay now we are ready to modify the snippet. Let's start with the header information:
For now, just change the Title and Shortcut to include your initials like this:
Since you are here to change the default value as well, locate the Default tag:
Change "True" to "False" then save the file and close it.
You are now ready to use your new snippet. Go into your code:
Type in your new snippet shortcut and hit TAB (once or twice, both work the same):
And you get the result:
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: