views:

37

answers:

2

I have been making several improvements on code snippets that are typically built into VS2010. Is there any way to either "prefer" certain snippet directories over others, or to overwrite the defaults without manually removing the references from the Code Snippets window? I would like to keep the same shortcuts.

This is mostly nit-picking, since I could remove the .snippet files manually, or remove the folder references, but I'm wondering if there is an easier way, incase I end up replacing a large amount of the default snippets yet still want to keep others.

There are two issues that come up when having similar shortcuts on code snippets.

  1. For some snippets, such as propdp, you will be prompted that there are multiple snippets, and be asked to choose which one is appropriate.
  2. For other snippets, such as ctor, it just uses the default snippet and pretends my own doesn't exist. Browsing the snippets using Ctrl+K,Ctrl+X clearly shows the snippet works, and the shortcut is correct.

The second issue here is a larger concern than the first.

Edit: Further experimentation shows that ctor in particular uses the default snippet no matter what. I haven't tried overwriting the code in the original snippet file, but removing the reference to Visual C# snippets folder still uses the default and ignores my replacement.

Edit 2: Even replacing the original snippet, ctor uses the default and ignores the .snippet file. This is after restarting Visual Studio as well. Now I have no idea where it's even retrieving this code snippet from. As a test, you can rename the snippet ctors and it will display properly. ctor is no longer a suggestion at this point. If you rename it back to ctor, it will once again display the default snippet. Either this snippet is cached somewhere, or it's built in to VS2010.

A: 

Have you tried simply overwriting the original files, replacing the snippet with your own?

They're located here: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#

MartinHN
I was just trying to create a more general-purpose solution. The problems I see with this is it requires finding the location of each snippet (for example, propdp is located in NetFX30, not Visual C#), requires administrator access to overwrite the files, and becomes a per-snippet process to install. I'm currently just dropping all my snippets in Dropbox and adding the folder reference in VS2010.
Will Eddins
Now, as I've stated above, I've learned that replacing the snippet for `ctor` ends up doing nothing. I have no idea where it's even retrieving this snippet from, perhaps its built-in to VS2010 and I can't override it.
Will Eddins
Maybe. I've only tried to overwrite existing snippets, and make brand new ones.
MartinHN
A: 

Have you looked at the plug-in for Code Barrel? It has revision support, tagging, etc... Looks like that may be what you need. ~shrug~ it is free, so is the plugin, go to codebarrel.com to get it.

Zdaxxy