Skip to main content
In this guide, you’ll learn how to use inline AI-assisted editing directly within your code editor. We’ll compare two common modes—separate chat windows versus inline prompts—and demonstrate how inline editing can streamline your workflow and reduce context switching.

Why Inline AI Editing?

  • Keeps you in the flow of coding
  • Provides suggestions as diffs you can accept or reject
  • Accelerates prototyping, refactoring, and helper-function generation
Inline prompts work best for focused, localized changes. For broad design discussions, consider a separate chat to maintain context.

Example: Simple Flask Authentication

Below is a minimal Flask app that demonstrates password hashing, an authentication decorator, and basic routes. We’ll use this code to show inline AI-powered enhancements.
Using SHA-1 for password hashing is not secure for production. Consider bcrypt or scrypt for real-world applications.

Inline Prompt vs Separate Chat

Most AI coding tools offer two modes. Choose based on your task:
ModeShortcutBest Use Cases
Separate ChatCommand L / Ctrl LDeep discussions, design reviews, large refactors
Inline PromptCommand K / Ctrl KQuick edits, helper functions, localized refactoring

Generating a Helper Function Inline

  1. Highlight the code location.
  2. Invoke the inline prompt (⌘-K / Ctrl-K).
  3. Ask for a helper function, e.g., “Create a function to reverse a string.”
The AI will generate:
Green lines indicate additions; red lines show removals. Press ⌘-Y / Ctrl-Y to accept or ⌘-N / Ctrl-N to reject.

Evolving Code with Inline Edits

You can request optimizations or new features inline. For example, add logging and error handling to your login_required decorator:
By refining code inline, you maintain momentum and iterate faster on performance, security, and feature improvements.

When to Use Each Mode

  • Separate Chat
    • Deep architectural discussions
    • Reviewing or documenting large codebases
  • Inline Prompt
    • Fast helper functions
    • Small bug fixes or refactors
    • Localized testing and debugging
Experiment with both to find the balance that boosts your productivity and minimizes context switching.

Watch Video