Visual Studio Code Snippets

by volkanuzun 2/20/2008 3:54:00 AM

I really like using code snippets in visual studio environment; unfortunately i dont have enough money to buy resharper :) so for code completion or code templates code snippets is my only choice. There are lot's of snippets that come with visual studio; they are stored @"D:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033" depending on your installation folder. As much as there is a lot, i would love to add my code snippets :) . All snippets files are xml files, and it has a structure that you have to learn, eventhough it is relatively easy i dont want to learn it :). I found this great tool that really helps you to create a snippet. You can download it from: http://billmccarthy.com/Projects/Snippet_Editor/ . Dont be mistaken with visual basic title, you can use it for c# too which actually i am using for. So you download this program, and run it, the rest is easy :). To show how it really is simple; lets create a snippet for console.writeline.
A lot of times i use Console.WriteLine("{0}",somevalue) , so why not use a snippet for it.

Run the snippet editor. Fill in the fields as below :

To add the the $param1$, first just write param1, select it with your mouse, right click on it, then select Add replacement. The snippet editor will create a variable, and wrap "param1" with $ and it will be changed to $param1$. This represents a variable in visual studio environment, so whenever you add this snippet, and use the tab key to iterate through your code, visual studio editor will select $param1$. Save this snippet to the code snippet folders of your own. Consuming it is very easy, while you are typing your code; just write consw (which is the shortcut we defined), and hit tab twice.  If you want to see a small flash video, here it is:

Tags:

Comments

3/20/2008 8:32:43 AM

James

but now you have ReSharper... Smile

James us

3/20/2008 9:27:02 AM

volkanuzun

and i am using it Smile thanx again

volkanuzun

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



About the author

Volkan Uzun




E-mail me Send mail

Twitter

Calendar

<<  December 2008  >>
MoTuWeThFrSaSu
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Flickr Badge

www.flickr.com
This is a Flickr badge showing public photos from volkanuzun. Make your own badge here.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in