Skip to content

"Surround with" in TypeScript/JavaScript via snippets #138564

@DanielRosenwasser

Description

@DanielRosenwasser

A while back, @mjbvz filed microsoft/TypeScript#18458 on the TypeScript side. The idea is that it would be great if we could easily transform.

// Hello
someFunc();
someOtherFunc();

into something like

if ([|condition|]) {
  // Hello
  someFunc();
  someOtherFunc();
}

as a refactoring. (The [|condition|] here represents a tab-stop where a user can start filling in condition as a placeholder).

The consensus there was that "surround with" is often simple enough that it could be provided through snippets. This won't always be precise, but it's good enough. Taking a look at the documentation, it seems like we can leverage $TM_SELECTED_TEXT in existing snippets to add this behavior.

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalityinsiders-releasedPatch has been released in VS Code InsidersjavascriptJavaScript support issuessnippetstypescriptTypescript support issuesverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions