Creating Code snippet file with the shortcut in Visual Studio 2010

This article will explain about how can we create the Code snippet with its shortcuts in easy way. It will be useful for all those who mainly works on the Maintenance project where they need to add the header of the file with the explanation that when the code was written and for what purpose and who has written it with the date etc.

Creating Code Snippet with the Short Cut in Visual Studio 2010

The article will explain that how can we create the Code snippet in Visual Studio 2010 including the comments which are required mostly in the maintenance projects where we need to write the Date, Name of the programmer who has made change in the file and the details of explanation about the changes are done in the current file.

To create the Code snippetin the Visual Studio 2010, we need to follow few steps:

1.Create the Code Snippet file:

Create New File
The snippet file is an XML file. So to create the XML file, just right click on the project solution or any XML file and change the extension to .snippet.
Add new XML file


Once the XML file is converted to .snippet file then open it in Visual Studio, you will see the XML format still.


The snippet extension .snippet is reserved in Visual Studio only for developing the Code Snippets shortcuts.


Now after creating the Code snippet file, we need to import it to the Visual Studio. To import the snippet file, go to the Tools --> Code Snippet Manager dialog.
code Snippet Manager Dialog
In the language Drop-down list, select the Language in which you have created the Code snippet i.e. C#. We can see below the language name, folder lists.
Select "My Code Snippets" folder and click on the Import button to import the code snippet file.
Import Code snippet file


After import, you can give the title name for your code snippet so that it can be created as shortcuts in your Visual Studio code files.
See the structure below to write the code snippet file:
Code Snippet Snapshot
Hope this article will help you all the members who are mainly involved in the maintenance projects where they need to show the header section of the file with the details of activity like who has created the file, modified with its date, purpose and other details.

With this article, we can generate lot of code snippets which can be used for the speed development in your development projects.

I am sending the snippet file as the attachment for the reference so that we can open directly this to our Visual Studio IDE.

I created an example of using the Code snippet with its shortcut FHC(File header Comment) and placed another .cs file which is using the FHC as the shortcut to create the whole header. The second attachment will show the .cs file as the attachment.
Use of Code snippet file


  • FileComments.snippet file (43654-1033-FileComment.snippet)
  • Example of using the Code snippet (43654-312336-CTSInvoiceBO.cs.txt)
  • Comments

    No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: