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.
| Tool | New line without sending | Notes |
|---|---|---|
| Codex CLI | Ctrl + J | The terminal-safe default. Shift + Enter is also bound but unreliable. |
| Claude Code | Shift + Enter | Or \ then Enter, which works in any terminal. |
| Gemini CLI | Ctrl + J | Inserts a newline without submitting. |
| opencode | Shift + Enter | Or Ctrl + J as the fallback. |
| Cursor CLI | Shift + Enter | Or Ctrl + J (useful under tmux). |
| Qwen Code | Shift + Enter | Or Ctrl + J. |
| Aider | Alt + Enter | Or wrap the message in { … }, or flip default behavior with /multiline-mode. |
| Grok Build | /multiline | xAI documents a multiline toggle rather than a single newline key. |
| Kimi Code CLI | Shift + Enter | Or Ctrl + J. Both are bound by default. |
| Kilo CLI | Shift + Enter | On Windows Terminal this needs a one-time settings.json change first. |
| Crush | Shift + Enter | Or Ctrl + J. Crush swaps its own help hint to whichever your terminal supports. |
| goose | Ctrl + J | The 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.
| Tool | Interrupt the task | Notes |
|---|---|---|
| Codex CLI | Esc | Interrupts the active task. (Ctrl + C here exits instead.) |
| Claude Code | Esc | Cancels the current request or input. Ctrl + C also interrupts. |
| Gemini CLI | Esc | Cancels the operation / dismisses a dialog. |
| opencode | Esc | Interrupts the running model. |
| Qwen Code | Ctrl + C | Cancels the request / clears input; press again (or on an empty line) to exit. |
| Aider | Ctrl + C | Interrupts Aider — the partial response is kept. |
| Kimi Code CLI | Esc | Interrupts the stream. Ctrl + C also interrupts — and Ctrl + S steers without stopping. |
| Crush | Esc | Cancels. Ctrl + C here quits outright, like Codex. |
| goose | Ctrl + C | Interrupts 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.
| Tool | Exit key | Slash command |
|---|---|---|
| Codex CLI | Ctrl + C | /quit or /exit |
| Claude Code | Ctrl + D | /exit |
| Gemini CLI | Ctrl + D (empty input) | /quit |
| opencode | Ctrl + C · Ctrl + X then Q | — |
| Cursor CLI | Ctrl + D (twice) | — |
| Qwen Code | Ctrl + C or Ctrl + D (twice) | /quit |
| Aider | Ctrl + C | /exit |
| Grok Build | — | /quit |
| Kimi Code CLI | Ctrl + D (twice) | /exit |
| Kilo CLI | Ctrl + C · Ctrl + X then Q | /exit |
| Crush | Ctrl + C | — |
| goose | Ctrl + 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
/quitor/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.