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