Thursday, March 7, 2013

Visual Studio Tip : Surround With

Something I use sparingly but find invaluable for my arsenal is the ability to quickly surround html elements with other elements. Especially useful when iterating over web design.

Select the section of code you want to surround with an HTML element:


Press the keyboard sequence Ctrl+(k,s)
I like to think of this as Control Code , Surround
You will get a popup like so:


 This popup works similar to how IntelliSense works i.e. type ht (to select html) and press tab to go into html submenu:



Similarly, Press di followed by tab to select and surround with div:

 One further mention , backspace key works as it normal in a text field when inside the surround with dialog.