Chat & Inline Editing
From the course Trae AI: ByteDance Code Editor
Trae's Chat and Inline Edit modes cover the majority of daily AI-assisted coding tasks.
Chat Mode
The chat panel is your conversational coding assistant:
- Ask questions about your codebase
- Request code explanations and reviews
- Generate new functions and components
- Debug errors by pasting stack traces
- Plan architecture and design decisions
Context Management
Add context to improve AI responses:
- @file — Reference specific files
- @folder — Include entire directories
- @web — Paste URLs for documentation reference
- @codebase — Let AI search your entire project
- @git — Reference recent commits and diffs
Inline Edit (Cmd/Ctrl+I)
The fastest way to make targeted changes:
- Select code (or place cursor on a line)
- Press Cmd/Ctrl+I
- Describe the change in natural language
- Review the diff and accept or reject
Inline Edit Examples
- Select a function → "Add error handling and input validation"
- Cursor in a file → "Add TypeScript types to all function parameters"
- Select a block → "Optimize this for performance, avoid unnecessary re-renders"
- Empty line → "Create a debounce utility function with TypeScript generics"
Chat vs. Inline Edit
| Scenario | Best Mode |
|---|---|
| Quick code change | Inline Edit |
| New file creation | Chat |
| Understanding code | Chat |
| Refactoring selection | Inline Edit |
| Multi-file changes | Chat → Builder |
| Debugging | Chat |
Applying Chat Suggestions
When chat generates code:
- Click "Apply" to insert at cursor position
- Click "Copy" to clipboard
- Use "Insert at cursor" for precise placement
- Code blocks show file paths for multi-file suggestions
Best Practice: Use @codebase sparingly — it sends your entire indexed codebase as context and consumes significant tokens. Prefer @file or @folder with specific paths for targeted questions. Save @codebase for architectural "where does X happen" questions.
Common Pitfall: Inline edit replaces selected text entirely. If you highlight a function and ask for "error handling", Trae will rewrite the function — not just append a try/catch. Narrow your selection to only the lines you want modified.
Effective inline edit: Select only the function body,
not the function signature, to prevent Trae from
renaming or changing the function's return type.
// Select from here:
const data = await fetch(url).then(r => r.json());
return process(data);
// To here (excluding closing brace)
Then: Cmd+I -> "Add try/catch with typed error logging"
Key Takeaways
- •Chat mode handles questions, generation, and debugging with full context
- •Inline Edit (Cmd/Ctrl+I) is fastest for targeted code modifications
- •Context references (@file, @folder, @web) dramatically improve AI accuracy
- •Choose the right mode based on task scope and complexity
Progress is kept in this browser only.