Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>Surround WithNew to Visual Studio Code? Get it now.
Surround With

Surround With

Dustin R. Callaway

|
8,849 installs
| (3) | Free
Surround selection with 'if' or 'try/catch' block in Visual Studio Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Wraps a code selection in an "if" or "try/catch" block with proper indentation

Surround With

This extension is patterned after IntelliJ's "Surround With..." command. It is based on and adds some bug fixes to this unsupported project.

Install

Install from VS Code with cmd+shift+x (or ctrl+shift+x on Windows), search for vscode-surround-with, and click "Install".

Usage

Select text to wrap with an if or try/catch block, press cmd+shift+p (ctrl+shift+p on Windows), and select one of the following:

  • Surround with if
  • Surround with try/catch

Release Notes

1.0.0

First release

1.1.0

Slightly modified the generated code

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft