dotnet thoughts 

a dotnet developer's technical blog

Increase your productivity using Visual Studio code snippets

In Microsoft VS 2005, Microsoft introduced a new functionality which helps developers to increase the productivity, Code Snippets.

The code snippets can be inserted using Right Click > Insert Snippet command (Image1).


Right Click > Insert Snippet(Image1)

And also you can use Snippet Manager(Image2), to check the shortcuts for snippets and by typing the shortcut and pressing [Tab] key will insert the snippet.


Snippet Manager (image2)

For inserting snippets for Property, type property and press [Tab] will insert code for a property(Image3)

Use the Snippet Manage to find the shortcuts, for Inserting snippets.

Some sample code snippets shortcuts

Foreach – For Each loop
For – for loop
Tryc – Try catch block
Trycf – Try Catch Finally block
If – If condition
Property – Property Declaration
Sub – Procedure Declaration
Function – Function Declaration

Property snippet inserted(Image3)

If you are not getting Snippet Manager, Right Click on Toolbar, Select Customize, from Command Tab, Choose Tools from Categories list, and drag Code Snippet Manager to the toolbar.  Also you can create your own snippets using SnippetEditor.msi from Microsoft, you can download snippet manager from Microsoft.
You can get more information about snippets from Visual Studio 2005 Code Snippets on MSDN and you can download Visual Basic Code Snippet Editor from MSDN.

Happy Coding :)

Update : If you are using Visual Studio 2008 – You will get a context menu item to show / hide snippet highlighting

No Responses to “Increase your productivity using Visual Studio code snippets”

RSS feed for comments on this post. TrackBack URL

Leave a Response

*