Surround with a Code Snippet

Keyboard:  CTRL + K, CTRL + S
Menu:  Edit -> IntelliSense -> Surround With
Command:  Edit.SurroundWith
Versions:  2008,2010
Published:  4/21/2010
Code:  vstipEdit0052

 

Download the seriously cool Tip of the Day Extension to get the daily tips delivered to your Start Page!

 

This is one that even people who know about snippets tend to forget.  You can actually put a snippet AROUND existing code.  Assuming you have some code selected:

image

 

Just press CTRL + K, CTRL + S:

image

 

Then type the statement you want to surround the code with.  In this case, I'll use an "if" statement:

image

 

Hit your TAB key once and you get your result:

image

 

Now you can put in your condition and any additional logic you want.  Pretty cool stuff!