New Line, Interrupt, and Exit in AI Coding CLIs

Terminal AI coding agents — Claude Code, Codex CLI, Gemini CLI, and the rest — share most of their keyboard layout. But three everyday actions are stubbornly inconsistent across them, and they're the ones you reach for constantly: writing a multi-line prompt without firing it off early, interrupting the agent mid-task, and exiting the tool. Guess wrong and you either send a half-finished message, can't stop a runaway edit, or accidentally quit the whole session.

This guide puts all three side by side, tool by tool. Every key here is drawn from each tool's own reference page — links to the full cheat sheets are at the bottom.

The Ctrl+C trap (read this first)

Ctrl + C does not mean the same thing everywhere, and that's the single biggest source of confusion. In Codex CLI a single Ctrl + C exits the whole session immediately. In Claude Code, Aider, and Qwen Code it interrupts the current task and you stay in the session — you need a second press (or an empty input line) to actually quit. So the muscle memory you build in one tool can drop you out of another. When you just want to stop what the agent is doing, Esc is the safer universal choice in most of these tools.

goose takes this furthest: its Ctrl + C is three keys in one. With text typed it clears the line; with a request running it interrupts that request; only on an empty, idle line does it exit. That makes it the most forgiving of the group — and the most likely to leave you pressing it twice wondering why nothing happened.

Add a new line without sending

By default Enter submits your prompt in every one of these tools. To write a multi-line message you need the newline key — and here's the catch: many terminals can't tell Shift + Enter apart from plain Enter. That's why several tools bind Ctrl + J (a real, distinct control character) as the reliable fallback. If Shift + Enter seems to do nothing, reach for Ctrl + J.

ToolNew line without sendingNotes
Codex CLICtrl + JThe terminal-safe default. Shift + Enter is also bound but unreliable.
Claude CodeShift + EnterOr \ then Enter, which works in any terminal.
Gemini CLICtrl + JInserts a newline without submitting.
opencodeShift + EnterOr Ctrl + J as the fallback.
Cursor CLIShift + EnterOr Ctrl + J (useful under tmux).
Qwen CodeShift + EnterOr Ctrl + J.
AiderAlt + EnterOr wrap the message in { … }, or flip default behavior with /multiline-mode.
Grok Build/multilinexAI documents a multiline toggle rather than a single newline key.
Kimi Code CLIShift + EnterOr Ctrl + J. Both are bound by default.
Kilo CLIShift + EnterOn Windows Terminal this needs a one-time settings.json change first.
CrushShift + EnterOr Ctrl + J. Crush swaps its own help hint to whichever your terminal supports.
gooseCtrl + JThe only one you can reconfigure — set GOOSE_CLI_NEWLINE_KEY.

Codex CLI's newline key generates more searches than any other key on this page. If that's what brought you here, the dedicated Codex CLI new line guide goes further — why Shift + Enter silently submits, and how to fix it in iTerm2, Windows Terminal, VS Code, and tmux.

Interrupt a running task (stay in the session)

When the agent is off doing the wrong thing, you want to stop it without quitting. Esc is the cleanest way to do this in most of the tools; Ctrl + C works too but — per the trap above — can exit outright in some.

ToolInterrupt the taskNotes
Codex CLIEscInterrupts the active task. (Ctrl + C here exits instead.)
Claude CodeEscCancels the current request or input. Ctrl + C also interrupts.
Gemini CLIEscCancels the operation / dismisses a dialog.
opencodeEscInterrupts the running model.
Qwen CodeCtrl + CCancels the request / clears input; press again (or on an empty line) to exit.
AiderCtrl + CInterrupts Aider — the partial response is kept.
Kimi Code CLIEscInterrupts the stream. Ctrl + C also interrupts — and Ctrl + S steers without stopping.
CrushEscCancels. Ctrl + C here quits outright, like Codex.
gooseCtrl + CInterrupts the request and resets to before it started — but see the note below.

Grok Build, Cursor CLI, and Kilo CLI don't publish a distinct interrupt key in their official references, so they're left off this table rather than guessed at.

Kimi Code CLI is the one tool here with a third option. Instead of interrupting and re-prompting, Ctrl + S injects your correction into the turn that's already running, so the model course-corrects without losing its place. Nothing else in this list does that.

Exit / quit the tool

Two reliable patterns show up everywhere: a slash command (/quit or /exit) and a control key. The control key is where they diverge — Ctrl + D is the common "exit on empty line" convention, while Codex uses Ctrl + C.

ToolExit keySlash command
Codex CLICtrl + C/quit or /exit
Claude CodeCtrl + D/exit
Gemini CLICtrl + D (empty input)/quit
opencodeCtrl + C · Ctrl + X then Q
Cursor CLICtrl + D (twice)
Qwen CodeCtrl + C or Ctrl + D (twice)/quit
AiderCtrl + C/exit
Grok Build/quit
Kimi Code CLICtrl + D (twice)/exit
Kilo CLICtrl + C · Ctrl + X then Q/exit
CrushCtrl + C
gooseCtrl + C (empty line)/exit or /quit

When in doubt, type /quit or /exit — a slash command never accidentally interrupts a task, so it's the safest way to leave any of these tools cleanly.

Kimi Code CLI adds a confirmation step that the others don't: the first Ctrl + D only shows a prompt in the status bar, and a second press actually exits. If you pressed it once and nothing happened, that's why. For Codex specifically, the dedicated exit guide covers what happens to your session and how to resume it.

What about the browser chat apps?

If you searched for how to go to the next line in Gemini, Perplexity, Claude, or ChatGPT, the answer is simpler: in the browser and desktop chat apps, Enter sends and Shift + Enter makes a new line — uniformly. The terminal-distinguishability problem that forces Ctrl + J in the CLIs doesn't exist in a web page, so Shift + Enter just works. To start a fresh conversation, most use Cmd/Ctrl + Shift + O (ChatGPT, Gemini, Grok), while Claude uses Cmd/Ctrl + O. See the AI chat shortcuts comparison for the full set.

The quick answer

  • New line without sending: Ctrl + J is the universal fallback; Shift + Enter works in many tools if your terminal supports it.
  • Interrupt a task: Esc in most tools (Claude Code, Codex, Gemini CLI, opencode); Ctrl + C in Aider and Qwen Code.
  • Exit: type /quit or /exit — or Ctrl + D (most) / Ctrl + C (Codex, Aider, opencode, Crush).
  • Remember the trap: Ctrl + C quits Codex and Crush outright, only interrupts Claude Code, Aider, and Qwen Code, and does all three things depending on context in goose.