Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>VSCode SurroundNew to Visual Studio Code? Get it now.
VSCode Surround

VSCode Surround

artizon

|
787 installs
| (1) | Free
A vscode extension analogous to *vim-surround
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VSCode Surround

A vscode extension analogous to *vim-surround

How it works?

We simultaneously search for the nearest substring pair (position relative to the cursor) that matches the specified start and end patterns respectively. The search process will not take AST into account. Currently, VS Code doesn't expose any AST information in its Extension API.

Default Patterns

The following selection patterns are provided out-of-the-box:

  • <>
  • {}
  • []
  • ''
  • ""
  • ()
  • `
  • ```

Custom Pattern

Custom selection patterns can be specified in Preferences. Match patterns are specified as Javascript regular expression strings. An example configuration is given below. Custom pattern 2 here formulates a typical Typescript function declaration. Notes that this custom pattern is fragile. We recommend keeping the patterns simple.

{
  "vscode-surround.custom-patterns": {
    "1": {
      "startPattern": "\\(",
      "endPattern": "\\)"
    },
    "2": {
      "startPattern": "function \\w+\\([^\\n]*\\)(: \\w+)? {",
      "endPattern": "}"
    }
  }
}
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft