From the course: Visual Studio Developer Tips

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Surround a block of code with a code snippet

Surround a block of code with a code snippet - Visual Studio Tutorial

From the course: Visual Studio Developer Tips

Surround a block of code with a code snippet

- [Teacher] In this video I'll look at the Surround With feature. It's really a special form of code snippets, one that knows how to expand a code snippet around an existing block of code without destroying it in the process. I'll start by looking at how you use a code snippet. I'll use the try snippet. So you type in "T-R-Y" and then you get this Intellisense in the autocomplete window. I also can read that I can press the Tab twice to insert the try snippet. So let's do that, press the Tab key twice. And that stubs in the body of the snippet, which is a try block and a catch block. But now I have to take my code and cut it and paste it. So let's use the surround with so I don't have to do that extra step. Put my code back in here. Then I'll select it and then right-click and choose Surround With. Also note the keystroke "Control+K", "Control+S". I'll use that later. So I choose Surround With. This autocomplete list gives me a short list of snippets that are surround-with-aware. In…

Contents