Question
How to replace the default "region...endregion" option with "#region...#endregion" in the Surround With menu in JetBrains IDEs?
Answer
You can add your own Surround With option to insert //#region / //#endregion so it’s recognized by VS Code and JetBrains IDEs. Here’s how:
- Open Settings | Editor | Live Templates.
- Click + in JavaScript → Live Template.
- Fill in:
-
Abbreviation:
vsc-region -
Description:
VS Code style //#region surround -
Template text:
//#region $REGION$ $SELECTION$ //#endregion
-
- Click Define… and enable JavaScript and TypeScript
- Apply and save.
To check that it’s working:
-
In a
.tsor.jsfile, select some code. -
Press Ctrl+Alt+T (Windows/Linux) or ⌥⌘T (macOS).
-
Choose vsc-region. It should wrap your selection like:
//#region myRegion ...code... //#endregion -
You can fold/unfold it in JetBrains IDEs, and VS Code should recognize it too.
Comments
0 comments
Please sign in to leave a comment.