How to Create Visual Studio Snippets

0 Flares Twitter 0 Facebook 0 StumbleUpon 0 Google+ 0 LinkedIn 0 0 Flares ×

One thing I really like in Visual Studio is code snippets – I use them quite a lot and find they can really help my productivity when I’m in hardcore coding mode. The other thing I like is how easy they are to create – you just create your .snippet file, drop it in relevant snippet directory, restart visual studio and off your go.

Here’s a couple of my favourite snippets that I use regularly:

My first one is really simple – when I’m unit testing I like the basic outline of of a test method to include the comments for arrange, act and assert – just for clarity and readability. So I created a snippet that gives you the following layout (triggered using “test” followed by double tab):

The other one I’ve attached was my lazy loaded property snippet – I find myself using lazy loaded properties quite a lot. This one is triggered using “propl”, and outputs something like this:

To use either of these snippets just add them to the c# snippet folder (for me its “C:\Program Files\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#\”), restart visual studio, and you should be good to go.

, ,

The Essential App Marketing Kit
Subscribe To My Newsletter To Get an Entire Chapter From The Book for FREE
Never display this again
0 Flares Twitter 0 Facebook 0 StumbleUpon 0 Google+ 0 LinkedIn 0 0 Flares ×