Creating your own Visual Studio code snippets

by robotix1986 19. July 2009 11:44

So just some time back I got thinking... everytime I start reading mails in the C# discussion alias at my company or Eric Lippert's explanations in them... the first thing I do is open up my very extensively used Console Application project in Visual Studio, comment out the existing main function for future reference and start writing a new one... and it is kind of a pain to do this.. so I thought that it's time to get it automated.. so I wrote a snippet to do that for me.

Below is the code for that: -

<?

xml version="1.0" encoding="utf-8" ?>
<
CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <
CodeSnippet Format="1.0.0">
        <
Header>
            <
Title>mainfn</Title>
            <
Shortcut>mainfn</Shortcut>
            <
Description>Code snippet for 'Main' function</Description>
            <
Author>Alvaro Rahul Dias</Author>
            <
SnippetTypes>
                <
SnippetType>Expansion</SnippetType>
                <
SnippetType>SurroundsWith</SnippetType>
            </
SnippetTypes>
        </
Header>
        <
Snippet>
            <
Declarations>
                <
Literal>
                    <
ID>expression</ID>
                    <
ToolTip>Code in main method</ToolTip>
                    <
Default>Console.WriteLine("Hello World!");</Default>
                </
Literal>
            </
Declarations>
            <
Code Language="csharp"><![CDATA[ public class MyClass
            {
                public static void Main()
                {
                    $expression$
                    $selected$ $end$
                }
            }
]]>
            </
Code>
        </
Snippet>
    </
CodeSnippet>
</
CodeSnippets>


Most of the fields above are self explanatory. I'll explain a few important ones.
The <Shortcut> tag specifies what you need to type in VS to use this snippet.
<SnippetTypes> - where you can use this snippet, Expansion, Surround With or both.
<Code Language="csharp"> - the actual code to be inserted

Interesting thing to note is that all the variable items are marked with $ signs. The $selected$ attribute signifies where the selected code should go in case you use this code as a sorround with snippet.
The $end$ attribute signifies where the cursor should go once you're finished with the snippet.

Hope the above helps in your coding adventures.


Regards,
AlD

Tags: , ,

.NET

Comments

10/10/2009 12:00:18 AM #

Blocked Drain

I have been experimenting with the express editions of Visual Studio to develop my knowledge for a number of months and  am starting to make the conversion to the professional edition. In advance of this I would like to improve my  knowledge of using the tool before I spend real money. My earlier experience is as a web coder with php, mysql, most linux based tools and a little flash, now I am moving to a Microsoft package. I am finding it is a large learning curve and am attempting to build my awareness with some  blog reading.  The phrase " Creating your own Visual Studio code snippets " in your post got me aroused my curiosity.  I feel the Visual Studio tutorial web sites  are oftentimes inflexible and mention the identical items looking like an online manual.  Dialog in blogs often cover actual ways to overcome issues that takes me through the learning curve more quickly.  Thanks for the note.

Blocked Drain United Kingdom | Reply

10/11/2009 8:52:37 PM #

cash advance

I never thought of that this way .. good writing.

cash advance United States | Reply

10/15/2009 5:04:29 PM #

no teletrack payday loans

Interesting information. May I add this blog to my linkexchange directory ?

no teletrack payday loans United States | Reply

10/22/2009 12:44:02 PM #

robotix1986

sure... go ahead... glad all of you liked this post

@david.. that's true... coz a lot of people blog when they face issues and/or overcome them

robotix1986 India | Reply

12/1/2009 1:09:10 AM #

payday loans

thanks!  very helpful post!! like the template btw ;)

payday loans United States | Reply

12/17/2009 11:10:31 AM #

anonymous proxy

Great insights. I loved to read your article. You must be putting a lot of time into your blog!

anonymous proxy Thailand | Reply

12/18/2009 5:42:50 AM #

Hirephpdevelopers

There are Applications project in Visual Studio.Nice informative guideline  

Hirephpdevelopers United States | Reply

12/18/2009 9:05:10 AM #

proxy

Great share. Keep up the good work.

proxy Thailand | Reply

12/18/2009 7:50:56 PM #

Skin care

Your post give me some idea. Thank you.

Skin care Thailand | Reply

12/18/2009 10:15:46 PM #

Camera lense

Excellent post.

Camera lense | Reply

12/18/2009 11:13:49 PM #

Digital camera

Great post. I like it.

Digital camera United States | Reply

12/22/2009 11:41:14 AM #

ผลบอล

This is a very nice post.

ผลบอล Thailand | Reply

12/23/2009 1:58:13 AM #

unblock myspace

Great blog, this could be the best blog I ever visited thi month. Never stop to write something useful dude!.

unblock myspace | Reply

12/25/2009 1:54:34 AM #

Gamefly

Its an amazing post .I had been searching for the information from long time thanks for the post.

Gamefly United States | Reply

12/25/2009 1:59:26 AM #

Payday Loans

I was looking for this information since a long time. You have really fininshed my search by posting this here. It will proven to be very beneficial for me

Payday Loans United States | Reply

12/25/2009 3:13:00 AM #

paydayloans

I like what I see. keep it going

paydayloans United States | Reply

12/29/2009 6:21:56 PM #

Ggler

Nice post. I love it.

Ggler United States | Reply

1/7/2010 9:56:46 AM #

zygor guides

You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

zygor guides United States | Reply

1/8/2010 9:51:12 PM #

Mobilt bredbånd

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

Mobilt bredbånd United States | Reply

1/10/2010 7:18:24 AM #

feline behavior

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.

feline behavior United States | Reply

1/14/2010 12:35:20 AM #

offshore havens

Well, this is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a marvellous job!

offshore havens United States | Reply

1/16/2010 6:48:27 AM #

airsoft guns

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.

airsoft guns United States | Reply

1/16/2010 2:45:30 PM #

stock loan

Valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!! Thumbs up

stock loan United States | Reply

1/24/2010 6:33:25 AM #

cash advance

is that all you can say about this ? hmm ..

cash advance United States | Reply

1/24/2010 7:39:30 AM #

nine west ankle boots

Keep 'em coming... you all do such a great job at such Concepts... can't tell you how much I, for one appreciate all you do!

nine west ankle boots United States | Reply

1/31/2010 12:01:38 AM #

cash loans

For success, attitude is equally as important as ability.

cash loans United States | Reply

1/31/2010 7:28:14 AM #

contractor accountant

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

contractor accountant United States | Reply

2/2/2010 12:43:43 AM #

beyerdynamic dt 880 headphones

This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article

beyerdynamic dt 880 headphones United States | Reply

2/3/2010 12:28:50 PM #

ekstern backup

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

ekstern backup United States | Reply

2/4/2010 2:27:02 PM #

payday loans

There is joy in work. There is no happiness except in the realization that we have accomplished something.

payday loans United States | Reply

2/6/2010 10:01:18 AM #

online payday loans

There is joy in work. There is no happiness except in the realization that we have accomplished something.

online payday loans United States | Reply

2/7/2010 3:19:35 AM #

how to get rid of fat

Hi. this is kind of an "unconventional" question , but have other visitors asked you how get the menu bar to look like you've got it? I also have a blog and am really looking to alter around the theme, however am scared to death to mess with it for fear of the search engines punishing me. I am very new to all of this ...so i am just not positive exactly how to try to to it all yet. I'll just keep working on it one day at a time.

how to get rid of fat United States | Reply

2/7/2010 4:19:25 AM #

fast payday loans

Do not go where the path may lead, go instead where there is no path and leave a trail.

fast payday loans United States | Reply

2/11/2010 2:09:07 PM #

contractor accountant

Do you accept guest posts? I would love to write couple articles here.
I was wondering what is up with that weird gravatar??? I know 5am is early and I'm not looking my best at that hour, but I hope I don't look like this! I might however make that face if I'm asked to do 100 pushups. lol

contractor accountant United States | Reply

2/11/2010 6:54:55 PM #

Emergency Plumbers Fort Worth

How does this code work since its not a html nor PHP

Emergency Plumbers Fort Worth United States | Reply

2/14/2010 3:05:38 PM #

Culver City Garage Door Repair

The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!

Culver City Garage Door Repair United States | Reply

2/17/2010 1:59:59 AM #

vilantae

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.

vilantae United States | Reply

2/19/2010 4:25:49 AM #

Gettysburg PA restaurants

When I originally commented I clicked the "Notify me when new comments are added" checkbox and now each time a comment is added I get four emails with the same comment.
Is there any way you can remove me from that service?
Thanks!

Gettysburg PA restaurants United States | Reply

2/20/2010 3:45:49 PM #

stock charts

I'm curious what CMS your site uses? It looks really good and I like all the visitor functions that are available. Sorry if this is the wrong place to ask this but I wasn't sure how to contact you - thanks.

stock charts United States | Reply

2/20/2010 11:25:39 PM #

Daniel Millions

I was wondering if you would be interested in becoming a guest poster on my blog? In exchange you could put one link your post? Please reply when you get a chance and I will send you my contact details - thanks.

Daniel Millions United States | Reply

2/21/2010 10:15:18 PM #

stock broker

In most occassions I don’t post comments on blogs, but I'd like to say that this post really forced me to do so. Thanks!

stock broker United States | Reply

2/22/2010 10:59:09 AM #

Daniel Millions

Just wanted to say that you have some awesome content on your blog. If it's allowed I would like to use some of the information you provided on my blog. If I link back to this page would it be OK to do so?

Daniel Millions United States | Reply

2/23/2010 2:29:00 PM #

aloe products

Great thread.  Enjoyed the posts..

aloe products United States | Reply

2/24/2010 10:47:19 AM #

debt consolidation

I would like to use some of your material for my website. Please let me know if that's OK and I will link back to this page.

debt consolidation United States | Reply

2/24/2010 4:46:46 PM #

key west fishing charter

If you are looking for information on fishing in Key West or Key West fishing guides, check out this site- http://www.keywestcustomcharters.com Tight lines!

key west fishing charter United States | Reply

2/26/2010 12:50:47 AM #

Verkaufsdisplay

Very informative text. I've found your blog via Google and I'm really glad about the information you provide in your posts. Btw your sites layout is really broken on the Chrome browser. Would be really great if you could fix that. Anyhow keep up the good work!

Verkaufsdisplay Germany | Reply

2/27/2010 2:13:04 AM #

Verkaufsdisplay

Very informative article. I've found your blog via Google and I'm really glad about the information you provide in your articles. Btw your blogs layout is really messed up on the Chrome browser. Would be really great if you could fix that. Anyhow keep up the good work!

Verkaufsdisplay Germany | Reply

2/27/2010 2:45:08 AM #

Fatcow Review

Should I get a VPS?  I am using lunarpages but they keep shutting me down due to high server overload. Im getting about 2,000 unique views a day. What brand should I get?

Fatcow Review United States | Reply

2/27/2010 3:04:28 AM #

business directory

Do have an email system where I can get your blog posts emailed to me?

business directory United States | Reply

2/27/2010 8:09:07 AM #

Amie

Reading nice blogs enable me to connect to other people and learn something new about their experiences.  Thanks for posting this.

Amie Syria | Reply

2/27/2010 9:20:19 AM #

std symptoms

Do you think you have STD symptoms?  See pictures here http://www.std-symptom.info and to find STD testing.

std symptoms United States | Reply

2/28/2010 7:06:03 AM #

Origins skin care

Hi
I found your site through search at google.  Your article very useful for me, maybe for other people too.  Big Thanks

Regards
Orie

Origins skin care Croatia | Reply

2/28/2010 4:28:20 PM #

tax lawyer

If you are having tax problems, find a tax lawyer here http://www.thebiglawyerdirectory.com tax lawyer directory

tax lawyer United States | Reply

3/1/2010 8:05:49 PM #

Watch Pacquiao Vs Clottey Live

your blog is very imformative and i learn a lot from it.
Thanks for sharing.

regards,

rosela

Watch Pacquiao Vs Clottey Live United States | Reply

3/2/2010 5:50:32 PM #

generic viagra pills

This truth holds for the buying and selling of medicinal drugs as well. Online pharmacies provide similar functions to those of the local pharmacy.

generic viagra pills United Kingdom | Reply

3/3/2010 6:18:24 AM #

viagra tablets for sale

This truth holds for the buying and selling of medicinal drugs as well. Online pharmacies provide similar functions to those of the local pharmacy.

viagra tablets for sale United Kingdom | Reply

3/3/2010 1:17:43 PM #

wow mobiles

WoW Mobiles is awesome! I get free mobile service with t-mobile because I refered 3 people to wow. You can too!

wow mobiles United States | Reply

3/3/2010 1:42:17 PM #

london escort girls

I love your blog, couse I can read it from my Nokia.

london escort girls Slovenia | Reply

3/3/2010 4:03:35 PM #

home insurance quote

Nice good but its having problems when you want to debug it ,thanks

home insurance quote United States | Reply

3/4/2010 3:37:48 AM #

hd movies

I like watching movies online, it is way easier than going to the theaters.

hd movies United States | Reply

3/4/2010 4:07:09 PM #

watch movies online

I like watching movies online, it is way cheaper than going to the theaters.

watch movies online United States | Reply

3/4/2010 11:03:21 PM #

Okna

Useful and nice article. I am going to subscribe your blog. Tnx.

Okna Slovenia | Reply

3/5/2010 5:11:15 AM #

hd movies

I like streaming movies online, it is way easier than going to the theaters.

hd movies United States | Reply

3/5/2010 5:29:56 AM #

Mission Hills Plumbing

Couldn?t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!

Mission Hills Plumbing United States | Reply

3/5/2010 6:50:38 AM #

roulette systems

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

roulette systems United States | Reply

3/5/2010 7:58:03 AM #

Buy ED Meds Cheap

So what are you doing now? Buy your cheap Viagra now.

Buy ED Meds Cheap United Kingdom | Reply

3/5/2010 9:16:46 AM #

stick of death game

Price tag puts, though the mortgage.

stick of death game Venezuela | Reply

3/5/2010 2:51:29 PM #

Yong Perque

1 from now...I told some of the dev's that some of the other dev's furnish remarks on QA defect tickets and that those were helpful to me. When I enquired these other devs why they didn't do the corresponding thing they said "nobody ever scans those" and "I don't have time for that" Uh, hello? Didn't I just articulate I study them? It's no coincidence that the devs who comment on their solutions have noticeably fewer defects in their computer code then the clump that think there is no time for remarks and no one scans them anyhow.

Yong Perque United States | Reply

3/5/2010 5:27:37 PM #

Owen Besarra

Useful article, this is very similar to a site that I have. Please check it out sometime and feel free to leave me a comenet on it and tell me what you think. Im always looking for feedback.

Owen Besarra United States | Reply

3/5/2010 8:01:58 PM #

Reagan Renegar

Hi. I just noticed that your blog looks like it has a formatting issue at the very bottom of your web page. I'm not positive if everyone is seeing this same bugginess when browsing your website? I am employing a completely different browser than most people referred to as Opera, so that is what might be causing it? I just wanted to let you know. Thanks for posting some great postings.

Reagan Renegar United States | Reply

3/6/2010 12:56:00 AM #

lower back pain cure

I retributive be in pair with your weblog! Very dandy stake! Nonetheless you can do various things to enrich it, and i faculty be game




Regards and respect
Barrett









lower back pain cure United States | Reply

3/6/2010 12:58:45 AM #

Pat Crook

Rather superb entry, definitely useful stuff. Never ever considered I'd find the facts I need right here. I have been looking everywhere in the internet for some time now and had been starting to get discouraged. Fortunately, I happened across your blog and received precisely what I was searching for.

Pat Crook United States | Reply

3/6/2010 3:56:34 AM #

Refer 3 Get Yours Free

Is tethering against the TOS of cell phone companies? Which ones allow it?

Refer 3 Get Yours Free United States | Reply

3/6/2010 11:27:38 AM #

free ovulation calendar

I am loving it LOL!! Will come back again - adding this to my rss feeds also, Thanks.

free ovulation calendar United Kingdom | Reply

3/6/2010 1:47:30 PM #

Mothercare

Pretty impressive article. I just stumbled upon your site and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.

Mothercare United Kingdom | Reply

3/6/2010 3:21:52 PM #

Tamatha Harrold

Very good site, where did you come up with the knowledge in this article? Im glad I found it though, ill be checking back soon to see what other articles you have.

Tamatha Harrold United States | Reply

3/6/2010 9:06:49 PM #

Evelyne Kudasik

Well said, you just earned another subscriber

Evelyne Kudasik United States | Reply

3/6/2010 9:47:20 PM #

boards

That is some inspirational stuff. Never knew that opinions could be this varied. Thanks for all the enthusiasm to offer such helpful information here.

boards United States | Reply

3/7/2010 12:59:11 AM #

quick personal loans

thanking you for providing such a great help

quick personal loans United States | Reply

3/7/2010 2:57:28 PM #

Hypnotism

Gday, I can’t understand how to add your web-site in my rss reader. Will  you Assistance me, please

Hypnotism Germany | Reply

3/8/2010 5:28:57 AM #

Arlinda Bardsley

I really like the fresh perpective you did on the issue. Really was not expecting that when I started off studying. Your concepts were easy to understand that I wondered why I never looked at it before. Glad to know that there's an individual out there that definitely understands what he's discussing. Great job

Arlinda Bardsley United States | Reply

3/8/2010 8:07:36 PM #

Yolanda Licalzi

great post, are you a professional writer?

Yolanda Licalzi United States | Reply

3/9/2010 12:17:44 PM #

mortgage loan modification

Hello, I have browsed most of your posts. This page iswhere I got the most useful information for my research. Thanks for posting, maybe we can see more on this. I also like this layout can you tell me where to get it  

mortgage loan modification United States | Reply

3/9/2010 6:10:21 PM #

the pacific episode 1

Olla.Hello.Forgive me if my english language is not good.however i only intend to say that i like this post so much.Thanxxx

the pacific episode 1 United States | Reply

3/11/2010 6:24:54 AM #

Malcolm McDowell

As a Newbie, I am always searching online for articles that can help me. Thank you

Malcolm McDowell United States | Reply

3/11/2010 2:31:13 PM #

hp printers

Just wanted to give you a shout from the valley of the sun, great information. Much appreciated.

hp printers United States | Reply

3/11/2010 6:28:56 PM #

Michael McDonald

Please, can you PM me and tell me few more thinks about this, I am really fan of your blog.

Michael McDonald United States | Reply

3/12/2010 1:17:14 AM #

Cheap Contact Lenses

Found this by accident. Really good read. Covers a nice info & looking forward to more. Would like to write my thoughts down in a blog like this; I just haven't got round to it so far.

Cheap Contact Lenses United Kingdom | Reply

3/12/2010 9:04:47 AM #

Paul

Hello, I'd just like to say, what a cool article! i'm just researching for my website but i had issues reading this article as the text protruding on to the side menu.... edit... sorry, the problems my end, it is my outdated version of internet explorer causing the fault. May be worth telling peeps to update. Keep up the good work.

Paul United Kingdom | Reply

3/12/2010 2:20:05 PM #

Fat Burning Furnace

I knew I was correct. My friend and I placed a bet about which web site was superior. I believed your webpage was better written, but she believed this article on trendy fashion tips was much better. We rounded up five family memebers who had not seen either site before to read them each more than. Majority chose your website. Thanks for maintaing a excellent site.

Fat Burning Furnace United States | Reply

3/12/2010 5:34:30 PM #

szybko schudnąć

Thanks for sharing, please keep an update about this info. love to read it more. i like this site too much. Good theme ;).

szybko schudnąć Poland | Reply

3/13/2010 4:22:10 AM #

mecze na żywo

Great article I've just added to my bookmark list.

mecze na żywo Poland | Reply

3/13/2010 8:31:20 PM #

how to lose weight naturally

There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game.

how to lose weight naturally United States | Reply

3/13/2010 9:52:37 PM #

how to loss weight fast

Bill you are definately proud of your work as you should be.  It is very well displayed.  congrats for the time you put into this.  I will dig and try to find some complimenting facts to add.  Thanks again.

how to loss weight fast United States | Reply

3/14/2010 7:31:14 PM #

Shryock

We should get in touch. Are you an active user on top social networking sites like Digg, Facebook, or Stumble Upon? If so, what is your username so we can get in touch to share ideas.

Shryock United States | Reply

3/15/2010 12:25:10 AM #

Privat Kredit

via Search engines although seeking for first help plus your location appears really exciting for me. Excellent

Privat Kredit Austria | Reply

3/15/2010 9:33:19 AM #

banners

Hi. I just noticed that your site looks like it has a few code errors at the very top of your website's page. I'm not sure if everybody is getting this same problem when browsing your blog? I am employing a totally different browser than most people, referred to as Opera, so that is what might be causing it? I just wanted to make sure you know. Thanks for posting some great postings and I'll try to return back with a completely different browser to check things out! Also, I put a link to your blog at my site,hope you dont mind?

banners United States | Reply

3/15/2010 9:50:12 AM #

Richard

Interesting. I was just having a scan around this sort of area & I wanted to point out to anyone who is just getting into this that although penny shares sound "cheap" beginners often think that they are more suited to people with less money. I would highlight that they are just as suitable for people with high net wealth because the truth is we need to look at percentage gains. Also - having someone with little money especially who is new to the markets start on penny shares is probably a bad idea (they cant be expeted to learn to trade on a stock that has such little accurate information out there!). Ive added this to my Mixx bookmarks.

Richard Paraguay | Reply

3/15/2010 10:35:09 AM #

Online Games

I've really liked reading your articles. You obviously know what you are talking about! Your site is so easy to navigate too, I've bookmarked it in my favourites :-D

Online Games United States | Reply

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About robotix1986

Yet another software developer in the software industry writing some kewl code and exploring new technologies when not doing the routine work stuff.

RecentComments

Comment RSS
Software Blogs - BlogCatalog Blog Directory