HCode VS Code Extension
VS Code extension version of the existing Python CLI project for adding Hinglish comments directly into C, C++, Java, and Python code with Gemini.
Features
- Comment selected code or the full active file
- Clickable status bar button for one-click use on supported files
- Editor title buttons so you can run HCode directly from the editor toolbar
- Branded HCode sidebar in the Activity Bar with a richer action panel
- Supports
cpp, c, java, and python
- Prompts for:
- language:
cpp, c, java, python
- mode:
function, line, full
- style:
simple, teaching, interview
- Replaces the same code in the editor with commented code returned by Gemini
- Optional preview command before replace
- Optional copy-to-clipboard flow
- Reads Gemini API key from VS Code settings or environment variables
- Wraps long
// comments so Hinglish text stays readable
- Uses the VS Code clipboard API, which handles Unicode well on Windows
Important Behavior
The prompt is designed to keep Gemini on a very strict contract:
- return only code
- keep the same language
- preserve original logic
- only add comments
- do not return markdown fences
The extension expects Gemini to return the same source code with comments inserted into that code.
Commands
HCode: Comment Selected Code
HCode: Comment Current File
HCode: Preview Commented Code
HCode: Copy Commented Code
Click-First Usage
You do not need to open the Command Palette.
- Open a
.cpp, .c, .java, or .py file
- Click the
HCode button in the status bar for the fastest flow
- Or click the HCode buttons in the editor toolbar
- Or click the HCode icon in the Activity Bar and use the sidebar panel
Comment Selected Code uses the current selection when present. If nothing is selected, it falls back to the full file and tells you.
Comment Current File always transforms the whole active document.
Preview Commented Code and Copy Commented Code follow hcpp.useSelectionIfAvailable.
Settings
{
"hcpp.geminiApiKey": "",
"hcpp.model": "gemini-2.5-flash",
"hcpp.temperature": 0.2,
"hcpp.useSelectionIfAvailable": true
}
API key lookup order:
hcpp.geminiApiKey
GEMINI_API_KEY
GOOGLE_API_KEY
Installation
- Install the extension from the VS Code Marketplace or install the
.vsix package.
- Set your Gemini API key in VS Code settings or environment variables.
- Open a
.cpp, .c, .java, or .py file.
- Click
HCode in the status bar, use the editor toolbar, or open the HCode sidebar.
Usage
- Select code, or leave nothing selected to use the full file.
- Run
HCode: Comment Selected Code or HCode: Comment Current File.
- Choose language, mode, and style from Quick Picks.
- Wait for Gemini to return the updated code.
- The extension replaces the selected range or the full document with the commented result.
After replacement, you can also copy the generated result from the success notification.
Install Notes
- Users do not need
npm install
- Users do not need
npm run compile
- The uploaded extension runs from the bundled compiled files
Notes and Limitations
- Long comment wrapping currently targets
// for C-family languages and # for Python.
- Markdown fences are stripped if Gemini returns them anyway, but the prompt strongly instructs Gemini not to add them.
- The wrapper uses lightweight line scanning for
// comments and may not perfectly reflow every unusual edge case involving comment-like text inside strings.
- The original Python CLI project is intentionally left untouched in its own workspace.