Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Visual Studio Toolbox: Creating and Using Code Snippets

Download

Right click “Save as…”

In this episode, we explore code snippets, an underappreciated feature of Visual Studio.

Code snippets are existing pieces of code. All you have to do is type the snippets shortcut and Visual Studio writes the code for you. Watch as we first use a couple of snippets that ship with Visual Studio. Then, see how to use the Snippet Designer extension and create your own snippets. With this extension, you can highlight code, right-click, and Export as Snippet. Very cool!!

Tags:

Follow the Discussion

  • GordonGordon

    I'm disappointed that snippets only work for vb and c#.
    But that does explain why this feature isn't used so much.

    Microsoft owned languages gets "special" treatment yet again.

    Disgusting !

  • magicalclickmagicalclick C9 slogan, #dealwithit. WinPh8.1 IE empty tab crash and removable video control edition.

    thanks for the vid. I didn't use it because it was confusing. But, now it make sense.

  • magicalclickmagicalclick C9 slogan, #dealwithit. WinPh8.1 IE empty tab crash and removable video control edition.

    Question:

    Why does VS C# Express doesn't have the same amount of Extensions? Like your Snippet Designer is not in there. I have VS Pro, but, I prefer to use Express and I wasn't able to get the extention for Express. Any reason why? Thanks.

  • @magicalclick:The Express editions do support extensions, but not all extensions support the Express SKUs. The author of the Snippet Designer built the VSIX to install on Pro and above. I don't know if this is because it won't work as well in Express, but I will ask him.

    Robert

  • Snippets can be a real time saver!  I've been using them for about year now, wish I had started using them earlier.

  • @magicalclick: I would love if I could have Snippet Designer support Express but the Express Sku's only support certain extensions which are specially signed by Microsoft. Even if I added Express to the list of editions in my VSIX it would still not run since Express won't let it. 

  • it's very hard to understand the code... quality is quite law

    any chance for high quality video?

     

    great video though !

    Thanks

  • @danfromisrael2: Are you watching the video in the browser? Did you download the High Quality WMV? The quality on that should be good.

    Robert

  • Great demonstration Robert.

    I'm a beginner in VS2010 and I can't make the ide to show the snippets directly with intellisense, How can you do that? Is a special command  needed to get that?

  • @HugoAgueroR:

    What version of Visual Studio do you have? Is it one of the Express products (VB, C#, Visual Web Developer)? Or is it Professional or Premium or Ultimate?

    And what type of project are you building and what type of file is open when you are trying to get snippets to work? Is it a vb or cs code file? An HTML page? An XML or XAML page?

    Robert

  • Thanks Robert

    I'm working with Visual Studio 2010 Ultimate. I'm using the snippets on a multilayer aplication that use WPF as a Presentation layer.  If I use the command Insert Snippet I can find my own snippets but It's not displayed directly on intellisense. The shorcut options works fine.

  • @HugoAgueroR:

    I apologize, but I am still not clear what isn't working. If you type ctrl+k+ctrl+x or if you right-click and select Insert Snippet or use the Insert Snippet command, you get a popup that shows the categories of snippets. Do all 3 of those work for you?

    If you type the snippet's shortcut and then press Tab twice, VS adds the code. Is that working for you?

    Robert

  • Informative, thank you, but god damn the poor quality of this video is making my head hurt.

  • @nocaffeine:Are you watching the video in the browser or did you download the WMV?

    Robert

  • @rogreen: Thanks Robert, all the methods work perfectly what I mean is that the name of the snippet don't appear automatically as I type.  If you look at the video at 11:57 as you type "propwithnotify"  you have intellisense showing the rest of the snippet name. I don't know why or I'm just a beginner but I thought that will help even more for a quick coding. Maybe I'm just doing the things wrong Smiley

  • @HugoAgueroR:Ahah! Now I see. Go to Tools|Options|Text Editor|C#. Make sure you check Show completion list after a character is typed. Click OK and see if it works now.

    Robert

  • @rogreen: OK perfect. Thanks

  • @HugoAgueroR:Glad we got this figured out! Smiley

  • salamsalam

    thanks for the video. I didn't use it because it was confusing.

  • Great toolbox video! Snippets has been one of those things I was always 'going to look at one day'. 

    Now I see the joy of those mysterious entries on the intellisense drop downs.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.