A Visual Studio Code extension that highlights the current Python cell (delimited by #%% or # %%) with a custom background color, similar to MATLAB and Spyder, like this:
Features
Automatically highlights the current Python cell as you move your cursor
Supports both #%% and # %% cell delimiter formats
Configurable background color
Toggle highlighting on/off with a keyboard shortcut
Installation
From VSIX File
Download the .vsix file
Open VS Code
Go to Extensions view (Ctrl+Shift+X)
Click the "..." menu at the top of the Extensions view
Select "Install from VSIX..."
Navigate to and select the .vsix file
Build It Yourself
Clone or download this repository
Ensure you have Node.js and npm installed. Typically you can install both by running the installer from https://nodejs.org/en. If you want to verify that node and npm are installed, open a command prompt and run:
node --version
npm --version
Open a terminal in the extension directory
Run the following commands:
# Initialize the npm project
npm init -y
# Install dev dependencies
npm install --save-dev @types/vscode eslint
# Install the packaging tool
npm install -g @vscode/vsce
# Package the extension
vsce package
This will create a .vsix file that you can install as described above
Requirements
VS Code version 1.99.0 or higher
Extension Settings
This extension contributes the following settings:
pythonCellHighlighter.backgroundColor: Sets the background color for the current cell (default: "rgba(100, 150, 255, 0.3)")
Keyboard Shortcuts
Toggle highlighting: Ctrl+Shift+H (Windows/Linux) or Cmd+Shift+H (macOS)
Using the Extension
The extension activates automatically when you open a Python file
It highlights the current cell (area between #%% or # %% delimiters)
The highlighting updates automatically as you move your cursor
Troubleshooting
If you encounter any issues:
Check the Output panel (View > Output) and select "Extension Host" from the dropdown
Make sure your Python files use #%% or # %% as cell delimiters
Try reloading the VS Code window (Developer: Reload Window from the command palette)
Development Guide
If you want to develop the extension further:
Clone the repository
Run npm install to install dependencies
Make your changes to the code
Press F5 to start debugging in a new VS Code window with the extension loaded