locked
Storing code snippets in C# Express Edition RRS feed

  • Question

  • I have started to create a couple of C# routines for console apps that would be easily reusable.

    I had a look at ways to store this code within the IDE and found a feature called code snippets. Unfortunately, the help for this doesn't work with the express edition. Creating the snippets also looks like a lot of work and I couldn't find a tool to speed this up for C# (I did find one for VB).

    I then found that you can simply drag and drop code into the general tab of the toolbox and click on that when you want to paste the code into a new project. The dead simplicity of this operation appeals to me over creating a complex(ish) XML file.

    Am I using the general tab as it was intended? Are there other techniques or tools for storing reusable code in MS C# 2008 Express Edition?


    One day, I may actually know a thing or two about C#
    Sunday, January 23, 2011 3:15 AM

Answers

  • Hi Cybersphere,

    a documentation of the Code Snippet System can be found here:
    - http://msdn.microsoft.com/en-us/library/ms165392(v=VS.90).aspx
    - http://msdn.microsoft.com/en-us/library/f7d3wz0k(VS.90).aspx

    Using the Toolbox is also completly ok, but AFAIK you cannot create shortcuts or use intellisense to add them to your code which is possible with Snippets and which can speed up your development when you can simply enter stuff and write code quickly on the keyboard.

    When using the Toolbox: Be aware, that you can create multiple Tabs with your own names to keep your Code Snippets sorted. And I am quite sure, that you already found the possibility to rename the Entry to whatever you want it.

    With kind regards,

    Konrad

    Sunday, January 23, 2011 8:32 AM
  • Code snippets are the way to store snippets of code.  This feature works on the Express products.   All you have to do is drop them into your per-user snippet directory.  Creating a snippet is definitely not intuitive but there are some ways to make it easier.

    My personal approach is to grab an existing snippet, copy it into my local snippet directory and then modify it to suit my needs.  I try to find the snippet most closest to what I want to accomplish. 

    Alternatively you can use the Code Snippet editor to create the snippets.  It allows to you create snippets and the latest version seems to be far easier to use than previous versions.

    Finally, code snippets are not really as powerful as you might hope.  They are really limited in what they can do.  To generate entire files or projects worth of code you'll want to move up to item and project templates (not sure how much these are supported in Express).  Finally there are third party addons that really expand upon this feature.  I personally use CodeRush from DevExpress for awesome snippets but, alas, addons do not work in Express versions.

    Michael Taylor - 1/23/2011
    http://msmvps.com/blogs/p3net

    Sunday, January 23, 2011 9:20 PM
    Moderator

All replies

  • Hi Cybersphere,

    a documentation of the Code Snippet System can be found here:
    - http://msdn.microsoft.com/en-us/library/ms165392(v=VS.90).aspx
    - http://msdn.microsoft.com/en-us/library/f7d3wz0k(VS.90).aspx

    Using the Toolbox is also completly ok, but AFAIK you cannot create shortcuts or use intellisense to add them to your code which is possible with Snippets and which can speed up your development when you can simply enter stuff and write code quickly on the keyboard.

    When using the Toolbox: Be aware, that you can create multiple Tabs with your own names to keep your Code Snippets sorted. And I am quite sure, that you already found the possibility to rename the Entry to whatever you want it.

    With kind regards,

    Konrad

    Sunday, January 23, 2011 8:32 AM
  • Code snippets are the way to store snippets of code.  This feature works on the Express products.   All you have to do is drop them into your per-user snippet directory.  Creating a snippet is definitely not intuitive but there are some ways to make it easier.

    My personal approach is to grab an existing snippet, copy it into my local snippet directory and then modify it to suit my needs.  I try to find the snippet most closest to what I want to accomplish. 

    Alternatively you can use the Code Snippet editor to create the snippets.  It allows to you create snippets and the latest version seems to be far easier to use than previous versions.

    Finally, code snippets are not really as powerful as you might hope.  They are really limited in what they can do.  To generate entire files or projects worth of code you'll want to move up to item and project templates (not sure how much these are supported in Express).  Finally there are third party addons that really expand upon this feature.  I personally use CodeRush from DevExpress for awesome snippets but, alas, addons do not work in Express versions.

    Michael Taylor - 1/23/2011
    http://msmvps.com/blogs/p3net

    Sunday, January 23, 2011 9:20 PM
    Moderator