Cmd+K (or Ctrl+K on Windows/Linux) on any selection to open an inline editing prompt, type your instruction, and watch the AI transform your code.
How It Works
Describe the change
Type a natural language instruction like:
- “add error handling”
- “convert to async/await”
- “add TypeScript types”
- “optimize this loop”
Example Workflows
- Add Error Handling
- Refactor to Modern Syntax
- Add TypeScript Types
- Optimize Performance
Before:Instruction:
add try-catch error handlingAfter:Documentation-Aware Editing
Quick Edit can scrape and use documentation from URLs included in your instruction.
Example: Using External Docs
Selected code:convert to React component using https://react.dev/reference/react/useState
Result:
Supported URL Patterns
Any HTTP/HTTPS URL in your instruction will be scraped:- Documentation sites (e.g.,
https://nextjs.org/docs/app/api-reference) - API references (e.g.,
https://docs.anthropic.com/en/api/messages) - GitHub READMEs (e.g.,
https://github.com/user/repo#readme) - Blog posts with code examples
Advanced Use Cases
Code Translation
Translate between languages or frameworks:Code Enhancement
Style Changes
Context Provided to AI
When you submit an edit instruction, the AI receives:- Selected code - The exact text you highlighted
- Full file context - The entire file for understanding surrounding code
- Your instruction - The natural language edit request
- Scraped documentation (if URLs present) - Markdown content from referenced URLs
UI Components
The Quick Edit tooltip appears directly below your selection and includes:- Text input - Enter your editing instruction
- Submit button - Apply the transformation
- Cancel button - Dismiss without changes
Tooltip Behavior
- Auto-focuses the input when opened
- Appears only when code is selected
- Automatically dismisses after successful edit
- Can be cancelled at any time
Keyboard Shortcuts
| Key | Action |
|---|---|
Cmd+K (Mac) / Ctrl+K (Windows/Linux) | Open Quick Edit on selection |
Enter | Submit instruction |
Escape | Cancel and close tooltip |
Implementation Details
Quick Edit is powered by Claude 3.7 Sonnet via the
/api/quick-edit endpoint./src/features/editor/extensions/quick-edit/index.ts:1 using:
- StateField - Tracks whether Quick Edit is active
- StateEffect - Triggers tooltip visibility
- Tooltip API - Renders the inline editing form
- Keymap - Binds
Cmd+Kto open the editor
Configuration
| Setting | Value | Location |
|---|---|---|
| Keyboard shortcut | Cmd+K / Ctrl+K | index.ts:178 |
| Model | Claude 3.7 Sonnet | route.ts:105 |
| Timeout | 30 seconds | fetcher.ts:29 |
| Placeholder text | ”Edit selected code” | index.ts:59 |
Error Handling
If you cancel a request (by clicking Cancel or closing the tooltip), any in-flight API request is aborted to save resources.Tips for Best Results
- Be specific - “add null checks” is better than “improve this”
- Select meaningful chunks - Select complete statements or logical blocks
- Preserve indentation - The AI maintains your original indentation level
- Include URLs - Reference docs directly in your instruction for framework-specific changes
- Iterate quickly - If the result isn’t perfect, select and edit again with refined instructions
Comparison with Other Features
| Feature | Use Case | Trigger |
|---|---|---|
| Quick Edit | Transform selected code with instructions | Cmd+K on selection |
| Suggestions | Auto-complete as you type | Automatic (300ms delay) |
| Conversations | Multi-file changes, complex tasks | Chat sidebar |
Related Features
- Ghost Text Suggestions - AI completions while typing
- Conversations - Full project AI assistant
- Documentation Scraping - Teach the AI with external docs