Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's Weblog

My adventures embracing open source on CodePlex and at Microsoft

News

    • Did you know... All author proceeds go directly to sending Hurricane Katrina survivors to college.

      Microsoft Visual Studio Tips book

      Recent Entries

Did you know... Ctrl+K, Ctrl+X inserts a code snippet - #103

In Visual Studio 2005, we introduced code snippets.  The VS Editor Team Blog has a nice write-up on code snippets, if you want to learn more instead of waiting for a tip here and there from me =)

So we're going to start the code snippet tip series with how to actually insert a code snippet.  The keyboard shortcut is Ctrl+K, Ctrl+X.  It is bound to the command Edit.InsertSnippet, in case your mileage varies, depending on your configuration settings.

I'm going to use C# for today's tip, but this applies to all languages that support code snippets.  When I invoke the Edit.InsertSnippet command, the code snippet insertion UI pops up.  Did you know... (the real tip here) that the snippet picker allows for type-ahead scrolling.  Note how I started typing "#re" on the line.  (oh, the fun i had testing this... but i digress...)

Code Snippet Insertion UI

Additional keystrokes:

  • You can hit tab to auto-complete the word.  If the word happens to be the code snippet (and not a folder), pressing tab will insert it.
  • You can also hit Shift+Tab to navigate back to the previous word (my contribution to the insertion UI)
Technorati tags: ,
Posted: Monday, December 10, 2007 3:00 AM by saraford

Comments

ccatto said:

Hey Now Sara,

I learned another little tip.

Thx 4 the info,

Catto

# December 10, 2007 12:22 PM

xjb said:

# December 18, 2008 7:41 PM
New Comments to this post are disabled
Page view tracker