Default Save Location

May 28, 2010 at 11:46 AM

Hi.  Does anyone know how to change the default location for saving new snippets?  It seems to love C:\Users\Mark\Documents\Visual Studio 2010\Code Snippets\Visual C#\My Code Snippets\ and I couldn't find anywhere in the various environment prefs to adjust it.

Cheers

Coordinator
May 28, 2010 at 4:12 PM
Currently, I do know make that choice configurable. The problem with doing so is that I believe that Visual Studio will only pick up snippet from certain location. So if you save it in a new place VS might not let you use it. -Matt
May 30, 2010 at 8:14 AM

Ah, that's a good point Matt.  Normally I avoid treasured things being put deep in my documents in case you forget to copy them when reinstalling windows, but I'll just have to keep that one in mind!  :)

Apr 3, 2012 at 12:30 PM
Edited Apr 3, 2012 at 1:08 PM

You can add folders and snippets to Visual Studio over Tools > Code Snippets Manager

I have created snippets with your extension and placed them in a custom folder, which i added to Visual Studio with Code Snippets Manager.

Your SnippetExplorer displayed the snippets just fine after a search, in the Visual Studio session i created them, but i couldn't open them. Got an error message.

However after a restart of Visual Studio, your SnippetExplorer doesn't find my snippets in the custom folder at all.

Edit:  Just found out where the custom folders are stored:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Languages\CodeExpansions\

There are multiple entries for each coding language with have a path folder containing a key with the name of the language and the value containing a string with all paths including custom paths seperated by ';'

 

Example:

Visual C#\Paths\

Key: Microsoft Visual CSharp

Value: Path;Path;...

 

Maybe someone can fix this.

Coordinator
Apr 3, 2012 at 3:28 PM

This may be a bug in Snippet Designer but there should be a simple workaround for it. Currently, the Snippet Designer does read those registery settings where VS stores its Snippet Directories however it seems to only do this the first time the plugin is ever loaded. After that is saves those initial values and doesn't update it. This means that if you add a new directory using "Tools > Code Snippets Manager" the Snippet Designer might not pick it up. I will look into to fixing this but in the meanwhile you can add your new folder to the Snippet Designers folder list under Tools > Options > Snippet Designer > Indexed Snippet Directories".  

 

Let me know if this helps.

 

 

-Matt