A VS Code extension that highlights Python code regions with colored backgrounds and provides a tree view for easy navigation.
Automatically highlights Python code regions using # region and #endregion comments:
# region Setup
import numpy as np
import pandas as pd
# endregion
# region Data Processing
data = np.array([1, 2, 3, 4, 5])
processed = data * 2
# endregion
# region Output
print(processed)
# endregion- Colored backgrounds - Each region gets a unique color based on its name
- Nested regions - Supports hierarchical region structures
- Auto-detection - Regions are highlighted automatically when you open or edit Python files
A dedicated tree view in the Explorer panel showing all regions in your Python files:
- Hierarchical view - Displays nested regions as expandable tree nodes
- Quick navigation - Click on any region to reveal it in the editor
- Line range info - Hover over a region to see its line numbers
- Refresh button - Manually refresh the region list
Execute any region directly in the Python Interactive window:
- Right-click on a region in the Region Explorer
- Select "Run in Python Interactive"
- The region's code is sent to the Jupyter/Python Interactive window
Note: Requires the Python extension with Jupyter support.
Quickly navigate to any region by clicking "Reveal in Editor" from the context menu.
Customize the region highlighting behavior through VS Code settings:
| Setting | Default | Description |
|---|---|---|
regionBackground.enabled |
true |
Enable or disable region background highlighting |
regionBackground.highlightOnlyLastRegion |
false |
Only highlight the region containing the cursor |
regionBackground.opacity |
0.15 |
Background opacity (0.0 - 1.0) |
regionBackground.saturation |
0.6 |
Color saturation (0.0 - 1.0) |
regionBackground.lightness |
0.85 |
Base lightness (0.0 - 1.0) |
- VS Code version 1.74.0 or higher
- Python language support (for syntax highlighting)
- Jupyter extension (optional, for "Run in Python Interactive" feature)
Add # region and #endregion comments to define code regions:
# region My Region Name
# Your code here
# endregionRegions can be nested within other regions:
# region Outer Region
x = 1
# region Inner Region
y = 2
# endregion
z = 3
# endregionAdd a keyboard shortcut for quick region refresh:
- Open Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) - Search for "Preferences: Open Keyboard Shortcuts"
- Search for "Refresh Regions"
- Assign your preferred keybinding
| Command | Description |
|---|---|
regionExplorer.refresh |
Refresh the region list |
regionExplorer.runInInteractive |
Run selected region in Python Interactive |
regionExplorer.revealInEditor |
Navigate to selected region in editor |
MIT License - see LICENSE for details.