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:
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.
2.Once the XML file is converted to .snippet file then open it in Visual Studio, you will see the XML format still.
3.The snippet extension .snippet is reserved in Visual Studio only for developing the Code Snippets shortcuts.
5.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.
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.
6.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:
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.
No responses found. Be the first to comment...