Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Universal RegionsNew to Visual Studio Code? Get it now.
Universal Regions

Universal Regions

AndyK

|
2 installs
| (0) | Free
Language-agnostic token-based regions with highlighting and folding.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Universal Regions

Universal Regions adds language-agnostic, token-delimited regions to every file type except extensions you explicitly exclude. A completed region is shaded and can be folded. An opened region with no matching end token is shaded red from its start through the end of the document.

Configuration

Add settings such as these to your VS Code settings JSON:

{
  "universalRegions.startTokens": ["#region", "//<"],
  "universalRegions.endTokens": ["#endregion", "//>"],
  "universalRegions.excludeExtensions": ["lock", ".js"],
  "universalRegions.backgroundOpacity": 0.12
}

Each start token is paired with the end token at the same list index. Both lists should therefore have the same number of entries. Unpaired entries are ignored. Tokens must not contain whitespace. The label is the remaining text after the opening token on that line. A normal region's color is deterministic from that label and the opening line number.

After changing Universal Regions settings, VS Code recomputes the folding ranges for open files automatically.

Pairing rules

Regions use a single stack. Opening tokens are pushed; an end token closes only the most recently opened region when it has the corresponding configured token pair. This means nested regions pair naturally. An end token that does not match the top open region is ignored, leaving that region visibly unclosed until a valid matching end token is encountered.

VS Code's standard Fold command and gutter controls expose the collapsible regions. Universal Regions uses a wildcard folding provider, so VS Code requests its regions alongside the folding providers registered by every language extension.

Test in VS Code

  1. Open this extension folder in VS Code.
  2. Run npm install once, then press F5 and choose Run Universal Regions.
  3. VS Code opens an Extension Development Host with test-fixtures/regions.anything as its workspace. Open that file to verify normal, nested, and unclosed regions.

The launch configuration compiles the TypeScript first. It requires Node.js and npm to be installed and available on your PATH.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft