Partilhar via


How to: Use surround-with code snippets

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

To use surround-with code snippets through the Edit menu

  1. In the Visual Studio IDE, open the file that you intend to edit.

  2. In the Code Editor, select text to surround.

  3. From the Edit menu, select IntelliSense and then select the Surround With command.

  4. Select the code snippet from the code snippet inserter and then press Tab or Enter.

    Alternatively, you can type the name of the code snippet, and then press Tab or Enter.

To use surround-with code snippets through the context menu

  1. In the Visual Studio IDE, open the file that you intend to edit.

  2. In the Code Editor, select text to surround.

  3. Right-click the selected text. Then, in the right-click context menu, select Snippet > Surround With.

  4. Select the code snippet you want from the code snippet inserter, and then press Tab or Enter.

    Alternatively, you can type the name of the code snippet, and then press Tab or Enter.

See also