Skip to content

Quick Start with Edit Feature

This guide explains how to use the built-in AI edit feature to make quick and precise code modifications directly in your files, along with keyboard shortcuts for accepting or rejecting changes.

How to Use the Edit Feature

The edit feature is a convenient way to make quick modifications to specific code and files. Select the code, describe the changes you want, and the AI will generate inline diffs (diff) in real-time, allowing you to accept or reject these changes.

The edit feature is recommended for small, targeted modifications, such as:

  • Writing comments

  • Generating unit tests

  • Refactoring functions or methods

How to Activate the Edit Feature

Select the code block you want to modify and press Cmd+I (Mac) or Ctrl+I (Windows/Linux) to activate edit mode.

If no code is selected, pressing Cmd/Ctrl+I will insert code at the current cursor position by default.

Once edit mode is activated, you can provide modification instructions.

How to Provide Modification Instructions

Describe the changes you want the AI to make to the selected code. For the edit feature, high-quality instructions should be relatively short and concise.

For longer or more complex tasks, consider using Chat Mode.

How to Accept or Reject Changes

The AI's suggested modifications are displayed as inline diffs within the selected text.

You can review each suggestion and use the following shortcuts:

  • Accept changes: Press Cmd+Opt+Y (Mac) or Ctrl+Alt+Y (Windows/Linux).

  • Reject changes: Press Cmd+Opt+N (Mac) or Ctrl+Alt+N (Windows/Linux).

You can also accept or reject all changes at once:

  • Accept all: Press Cmd+Shift+Enter (Mac) or Ctrl+Shift+Enter (Windows/Linux).

  • Reject all: Press Cmd+Shift+Delete (Mac) or Ctrl+Shift+Backspace (Windows/Linux).

To get new suggestions for the same code selection, press Cmd+I (Mac) or Ctrl+I (Windows/Linux) again to re-request AI suggestions.

How to Use the Edit Feature in IntelliJ IDEA

In IntelliJ IDEA-based IDEs, the edit feature appears as an inline popup.

How the Edit Feature Works

The system uses your selected code, the current file containing the selection, and your input instructions to prompt the model to edit the code accordingly. The model does not access any additional contextual information.

Edit Feature Workflow

When you trigger an edit operation, the system follows these steps:

  1. Collect Context: Gathers your selected code and the current file's content.

  2. Prompt the Model: Sends the collected context and your instructions to the model.

  3. Apply Changes: The model's response is streamed back to the selected code range and displayed as inline diffs.

If you accept the diff, the system removes the previously selected code lines; if you reject it, the model's suggested changes are discarded.