Tuesday, February 11, 2014

Tip 2.44: How to insert a code snippet around a block of code

"Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio", courtesy of 'Sara Ford'

Sara Ford's Blog

C# and XML support the Edit.SurroundWith command that will insert the desired snippet around the selected code (whether it is just a selected word, selected line, or entire function). The keyboard shortcut is Ctrl+K, Ctrl+S.

For example, the following illustration shows how to use the Surround With feature to insert a for loop around an existing for loop.

The result is a for loop inside a for loop, as shown here:

Happy Programming! =)
Posted by Nils-Holger at 1:44 PM with 0 comments.
Add Your Comment