Udostępnij za pośrednictwem


Did you know… You can insert a snippet via “tab tab” - #234

This was tip #7 from my TechEd 2008 VS IDE Tips and Tricks. A few months ago, I had dinner with Alan Stevens, Chris Woodruff, and a few others who were creating one of the Microsoft certification exams. One of the developers said, “hey sara, you need to blog about Snippet Tab Tab.” I was blown away. i had tested this feature inside and out, and never had heard of “tab tab.” It turns out that it is just the sequence of keystrokes you use to insert a snippet, but i never even thought to refer to it as the “tab tab” feature.

I’m not a C# developer.  I spent the majority of my time writing code in VB during my software testing days.  Whenever I need to use C#, i heavily rely upon code snippets, since i don’t recall the syntax off the top of my head.

When in the appropriate place in the editor, you can type in the keyboard shortcut of a snippet, like “for”

SnippetTabTab1

In this state, you can simply press tab twice to insert the snippet, or stated more market-ing-ly (if that’s a word), “tab tab.” 

Why twice?  Press it once to auto-complete statement completion.  If you just type ‘f’ for “for”, and the “for” is highlighted, you can just press tab once to complete the word for.  Press it twice to generate the snippet, since the cursor will be at the end of the word “for” in the editor.

SnippetTabTab2

And the moral of the story is “<snippet> tab tab.”

Technorati Tags: VS2005Tip,VS2008Tip

Comments

  • Anonymous
    June 09, 2008
    PingBack from http://auto.a-foton.ru/?p=1689

  • Anonymous
    June 10, 2008
    As it may not be immediately clear from the original post, this works in VB too!

  • Anonymous
    June 10, 2008
    Hi Sara, thank you for the now every day use tip "Tab Tab". I didn't realize that some commands like for, if, while etc. are existing as a snippet. Great!

  • Anonymous
    June 10, 2008
    A little snippet that I use from time to time when I need information on how long something takes. Type

  • Anonymous
    June 22, 2008
    thats awsome... i thought the tab-tab only works when using "prop" like "prop"+tab-tab and u get "public int MyProperty { get; set; }"... dint know it works with all keywords... great, great GREAT....

  • Anonymous
    June 22, 2008
    awesome!! and my thoughts and practice the same as what bit-flipper mentioned on properties tab tab. glad it works on other keywords too.. WOOHOO!!!

  • Anonymous
    June 24, 2008
    amazing i did not know that asp.net provides such help too. great

  • Anonymous
    June 25, 2008
    I noticed in VB... that you can just press Space once and it does the exact same thing... Or I might be completely wrong. =)

  • Anonymous
    July 02, 2008
    Excellent Tip Sara! I tried it in VB2005Express, type "for" then press tab once {market as snippet-tab} - provides same WONDERFUL "codesmithing" for you.  Then the highlighted fields the IDE gives you as "to change here" are now in the tab-order.  That's some good stuff there; as I was in the same boat, VB6 then C#, then back to VB6 and now VB.NET [don't ask] :-), so sometimes/often my syntax isn't the best, but I know what I want - this helps get me where I need to be.

  • Anonymous
    July 03, 2008
    Do you know where to find a list of available commands that support the tab+tab combo? I mean, we all know prop, for, foreach, event subscription via event += tab+tab (which is a life saver), try, switch (which works great when using fixed collections like structs since it creates the switch case instruction for every item in the collection and... I guess those are all I remember

  • Anonymous
    July 07, 2008
    do you have an tips on using the datarepeater when i use a datarepeater all of my formats disappear for dates, times, number and it goes back to the default i think. also the combobox does not work in a datarepeater.

  • Anonymous
    June 05, 2009
    Tip #0 Know your Keybindings! General Development Settings Searching Tips Tip #1 How to behold the power