Friday, 30 March 2012

Code snippets in Visual Studio

I must admit I was not a big user of snippets in programming. I used a few because they popped out in intellisense - for example while writing a for-each loop the snippet "foreach" comes up and we intuitively use it.

Never looked deeper to find other snippets. Today I realized I was at a big loss by not using them! Now I am never going to declare a property with all the key-strokes or writing if-else without using snippets. The no. of key strokes required are so less that it will improve developer's productivity by a good margin.

A few I like:
- mbox: If I use only this one it will save a lot of time for me.
- else: This one popped up in intelli sense but still didn't use it. 3 key strokes with snippet and 11 without
- prop: for automatically implemented properties
- ctor: for spitting out the constructor
- svm: for static void main

Other useful ones are 'surrounds with' snippets. Among these I like "try" which surrounds a code block with try-catch statement. What a time saver!

And another cool thing is we can add our snippets, it's just editing an XML file some where. I will see which ones are missing and add on my own. Should be fun.

(This reminds me there is so much still to learn and that even the smallest of things can be of BIG use)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.