DropComments is a Visual Studio Code extension that helps you automatically add comments to your code using AI. The goal is to make your code more readable and maintainable with minimal effort.
You can find the extension on the VS Code Marketplace
- Automatically generate code comments with AI assistance
- Support for 20+ programming languages with appropriate comment syntax
- Secure API key storage in VS Code settings
- Progress notifications during comment generation
- Smart comment formatting based on language
- Optional emoji-enhanced comments (toggle via setting)
- Right-click context menu integration for quick commenting
- An OpenAI API key (required for AI comment generation)
- Internet connection for API access
- VS Code workspace trust enabled
Install DropComments from the VS Code Marketplace (coming soon).
- Install the extension
- Open VS Code Settings (Ctrl+,)
- Search for "DropComments"
- Enter your OpenAI API key in the "Api Key" field
- Select the code you want to comment
- Open the Command Palette (Ctrl+Shift+P)
- Run "DropComments: Add Comments to Selection"
- Wait for the AI to generate comments
- Comments will be inserted above your selection
- Select the code you want to comment
- Right-click in the editor
- Choose "Add Comments with DropComments" from the context menu
- Wait for the AI to generate comments
- Comments will be inserted above your selection
Tip: To include emojis in generated comments, enable Settings > DropComments: Use Emojis.
TypeScript, JavaScript, Python, Java, C#, C++, C, Go, Rust, PHP, Ruby, Perl, Bash, PowerShell, SQL, HTML, XML, CSS, SCSS, Sass, Less
dropcomments.apiKey
: Your OpenAI API key (required)dropcomments.model
: AI model to use for generating comments (default:gpt-4o-mini
). You can set this to any supported OpenAI model name to balance cost, speed, and quality.dropcomments.commentStyle
: Comment style preference (default:succinct
). Choosesuccinct
for concise comments focused on key logic, ordetailed
for more explanatory comments with rationale and context.dropcomments.useEmojis
: Include emojis in generated comments (default: false). When enabled, the AI is instructed to add relevant emojis sparingly for clarity.dropcomments.apiUrl
: Custom API URL (optional). Set a custom base URL for the AI API to use local LLMs or alternative endpoints. Must be OpenAI Chat Completions-compatible. Leave empty to use the default OpenAI endpoint.
DropComments supports routing AI requests to custom endpoints, enabling the use of local LLMs or alternative AI providers:
- Open VS Code Settings (Ctrl+,)
- Search for "DropComments: Api Url"
- Enter your custom endpoint URL (e.g.,
http://localhost:8080
for a local LLM) - Ensure your endpoint is OpenAI Chat Completions-compatible
- Use your existing API key setting if required by your custom endpoint
Compatibility Note: Custom endpoints must implement the OpenAI Chat Completions API format. Popular local LLM frameworks like Ollama, LM Studio, and text-generation-webui provide OpenAI-compatible endpoints.
Security: Only use trusted endpoints. Your code will be sent to the configured URL for comment generation.
You can provide a custom prompt template for AI comment generation using the dropcomments.promptTemplate
setting.
- Leave empty to use the default prompt.
- Supports variables:
{language}
: Language ID of the code{code}
: Selected code{style}
: Comment style instruction (succinct/detailed){emojiInstruction}
: Emoji usage instruction
Example template:
You are an expert in {language}. Add comments to the following code:
{style}
{emojiInstruction}
Code:
{code}
Set your template in VS Code Settings > DropComments: Prompt Template.
- Automatically generate code comments with AI assistance
- Support for 20+ programming languages with appropriate comment syntax
- Secure API key storage in VS Code settings
- Progress notifications during comment generation
- Smart comment formatting based on language
- Optional emoji-enhanced comments (toggle via setting)
- Right-click context menu integration for quick commenting
- Customizable AI model and comment style settings for full control over output
- Custom prompt templates
Stay tuned for more impressive features!
Contributions are welcome! Please open issues or pull requests for suggestions and improvements.