Surround with a Code Snippet (C# Only)

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



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:



Just press CTRL + K, CTRL + S:



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



Hit your TAB key once and you get your result:



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