Sunday, April 22, 2012

Code Snippets


Introduction:

Snippet is a programming term for a small region of re-usable source code, machine code or text. Code Snippets provide a way for you to insert ready-made snippets of code into your projects.

Advantages:

  • Write once use anywhere: Reduce the repeatable writing of code effort.
  • Define/Maintain a Coding Standard to be used for any Project/Organization.
  • Easy to use as well as create and also easily maintainable.
  • Share with other developers.
  • Increase productivity by making coding faster.

Creating a Snippet File:

To create a snippet file, you must create an XML file, and then write the XML code that makes up your code snippet.
Following are the steps to create a snippet file:

Step1



Step 2



Step 3



Step 4



Step 5



Step 6


Manage Code Snippets:

The Code Snippets Manager allows you to set the directories and individual snippets that you want available to insert into your code.

To access the Code Snippets Manager :

      On the Tools menu, click Code Snippets Manager.

To add a directory to the Code Snippet Manager :

In the Language: drop-down list, select the language that you want to add a directory to.
Click Add. This opens the Code Snippets Directory window.
Select the directory that you want to add to the Code Snippets Manager and click ‘OK’. The directory will now be used to search for available code snippets.