SnippetManager

18 Mar

Updated 3/22/09: SnippetManager now copies the snippet to the clipboard when selected.

I’ve gotten a lot requests for the snippet manager I used at my Mix08 session.

So as promised, here it is for everyone who is interested: app, code.

The first incarnation of this application was done by Nick Kramer (Thanks Nick!).  I’ve tweaked it and added a WPF frontend.

How do I use it?

  • To use a snippet, drag the title of the snippet to the desired target app.
  • In order to move the app around, drag the black bottom portion of the window.
  • The topmost checkbox and load/close buttons work as you would expect.

If desired, you can start the app from the commandline:

snippetmanager.exe /notontop [snippetsfile] [snippetsfile] …

where /notontop indicates that the snippet manager should start out NOT being topmost.

What is the format of the snippet file?

The format of the snippet file is:

Line Meaning
/////////////////////////////// Separates the contents of one snippet from another snippet.
// First Snippet Title Indicates what the “title” for a snippet should be.

(Note: if a snippet does not have a title, the first line of the snippet appears in the snippet manager.)

————————– Separates sections of snippets and restarts numbering of snippets.
partial line:<content> Should treat <content> as part of an existing line.  (i.e. Snippet should not include a line break at its end.)
<other> Any other line is treated as the content of a snippet

Given the “exactness” of the file format, I’d recommend always copying and editing the sample snippet file.

The sample snippet file (which was used in the above screen shot) is included in the zip and shown below:

   1: ///////////////////////////////
   2: // First Snippet Title
   3:         <Style x:Key="TitleStyle" TargetType="TextBlock">
   4:             <Setter Property="FontSize" Value="35"/>
   5:         </Style>
   6: ///////////////////////////////
   7: // Second Snippet Title
   8: partial line:Style="{StaticResource TitleStyle}"
   9: ///////////////////////////////
  10: Snippet content (no title)
  11: ///////////////////////////////
  12: --------------------------
  13: ///////////////////////////////
  14: // Second Snippet Section
  15:         <ControlTemplate x:Key="SubmitButtonTemplate" TargetType="Button">
  16:             <Grid Width="70" Height="20"  Background="DarkGray">
  17:                 <TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="12" FontFamily="/fonts/IngebretsenNeato.ttf#Ingebretsen Neato" Text="Submit"/>
  18:             </Grid>
  19:         </ControlTemplate>

13 Responses to “SnippetManager”

  1. edddy 19. Mar, 2008 at 2:28 am #

    Central, we have a 4-0-4 at scorbs.com/snippetmanage/SnippetManagerCode.zip

  2. aquaseal 19. Mar, 2008 at 5:08 am #

    Try:
    scorbs.com/snippetmanager/SnippetManagerCode.zip

    just forgot to put the ‘r’ at the end of snippetmanager

    Great little tool to keep snippets at my fingertips, thanks!

  3. Dave 19. Mar, 2008 at 7:47 am #

    This is great!
    I saw you use it at MIX and asked Adam Kinney & Mike Harsh about it. They told me you wrote it and were going to blog it so I’ve been paying attention :)

    Thanks!

  4. Tom 19. Mar, 2008 at 2:08 pm #

    Nice! I saw this in your MIX presentation and it looked pretty cool, but one thing came to mind as I watched you use it. Wouldn’t it be easier on you (the presenter) if the program just copied the snippet to the clipboard when you clicked on it in the list, then you pasted it wherever you want? This seems like it could be quicker, easier, and less error prone than drag and drop. If you’re worried about signaling choice/use of snippet to the audience, maybe you could highlight the selected snippet in the list.

  5. www 26. Mar, 2008 at 8:01 pm #

    Perhaps I’m missing the point. There is already a snippet manager in Visual Studio. It’s been there since the first release of VS.NET. Just drag your code to the toolbox. How is your snippet editor better (other than having a WPF frontend)?

  6. Ivana 30. Mar, 2008 at 5:25 pm #

    Great app! When i saw it at mix videos i thought it was great and then i tried it and it is usefull thanks from argentina!!

  7. John 12. Apr, 2008 at 7:21 am #

    I’ve been looking for something seperate to Visual Studio as sometimes you want to past snippets into other applications as part of a presentation.
    But no luck :(
    Worked with VS but not with SQL, IE, notepad etc.
    Will have a look at the code and see if there is a way to do this – maybe the suggestion of using the clipboard is the way to go?

  8. Davide Vernole 15. Apr, 2008 at 10:51 am #

    Hi Karen,
    could you verify the code link? It seems to be broken, thanks.

  9. John E. 15. Apr, 2008 at 11:18 am #

    Visual Studio ships with a snippet editor. You can drag XML, code, XAML etc. to the ToolBox panel. You can create separate sections for snippets, for example, one for each presentation. Seems like you did a lot of work to create something that already exists.

  10. Dmitry 17. Apr, 2008 at 6:44 am #

    Thank you for making this available!

  11. Seraphy 28. Apr, 2008 at 3:28 pm #

    Hi Karen,
    please Verify your code link. I couldn’t download it

  12. timheuer 28. Apr, 2008 at 3:59 pm #

    @seraphy: just a small type in her URL, here it is: http://scorbs.com/snippetmanager/SnippetManagerCode.zip

  13. Erik van Appeldoorn 03. Nov, 2008 at 2:58 am #

    Hi Karen,

    Thanks for the snippets app. I asked for it during your great PDC session and it’s cool you have published it here.

    I really liked your session, well-prepared, good slides, clear demo’s, that’s the way I like to watch sessions, good job!

    So I see you like to travel. If you have plans to go to The Netherlands one day please drop me a mail so I can provide you of info of the best places to go to.

    bye Erik

Leave a Reply