Inspired by my recent post on C# code snippets, I found a little console app by Francesco Balena* that enumerates all the snippets on your system along with their shortcut text.
I improved his console app and turned it into a convenient IDE macro along the lines of my keyboard shortcut enumerating IDE macro:
Download the Snippet List Macro (3kb ZIP)
I found out the hard way that the snippet manager writes all of its changes to the registry. So I use the registry to enumerate all possible snippet paths (this picks up all the per-system snippets and per-user snippets) and also to locate the snippet XML index file that cross-references all the physical paths.
The macro defaults to enumerating the C# snippets, but you can change the _Lang variable to enumerate any available snippet library: VB, C#, J#**, and Xml.
This macro only works in Visual Studio 2005, obviously. Here's how to run it:
* One of my earliest coding heroes!
** Does anyone actually use J#? C'mon. Seriously.
The group of terms "Snippet enumeration macro" confused me at first. Was thinking Snippets + enums + C macros, all working together.
I get it now.
David Grant on March 2, 2006 10:40 AMDidn't work for me. After double-clicking, nothing happens...
Miguel on March 2, 2006 11:44 AMI found the guy that uses J#:
http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-csharp/37122/Want-to-switch-from-J-to-C-need-help
Rick Scott on March 2, 2006 11:56 AM> After double-clicking, nothing happens...
Check your "My Documents" folder for a file called "Visual Studio 2005 CSharp Code Snippets.htm"
Jeff Atwood on March 2, 2006 1:06 PMAdd a reference to System.xml in your Macro IDE and then it should work.
Vivek on March 2, 2006 1:38 PMI believe these guys are using J#: https://mvp.support.microsoft.com/communities/mvplist.aspx?Product=Visual+Developer+-+Visual+J%23
Ioan Bizau on March 2, 2006 2:22 PMOOOPS, you don't hide the email address???
me again on March 2, 2006 2:24 PM> Check your "My Documents" folder for a file called > "Visual Studio 2005 CSharp Code Snippets.htm"
Actually my system is localized to portuguese and so "My Documents" is so what called "Meus Documentos". That's probably one (localization) point.
I tried the console application by Francesco Balena and it worked fine...
> so "My Documents" is so what called "Meus Documentos". That's probably one (localization) point.
Shouldn't be, because I query the registry key to get the root path, and I use Environment.GetFolderPath(SpecialFolder.MyDocuments) to fill in the expansion vars in that path.
Unless the registry key names themselves are localized?
> I tried the console application by Francesco Balena and it worked fine...
Be careful, because he doesn't pick up anything from the registry. Which means if you've set any snippet paths up in the Snippet Manager (which writes exclusively to the registry), those snippets won't show up.
Jeff Atwood on March 2, 2006 5:58 PMAlso, I just fixed a bug where only HKLM was checked for snippet paths. Now it checks in both HKCU and HKLM. What's really aggravating is that the language names are different in each part of the tree:
HKLM\Software\Microsoft\VisualStudio\8.0\Languages\CodeExpansions\CSharp
HKCU\Software\Microsoft\VisualStudio\8.0\Languages\CodeExpansions\Visual C#
I kid you not..
Jeff Atwood on March 2, 2006 6:02 PM| Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved. |