How to Add a New Line in Codex CLI

Press Ctrl + J to add a new line in Codex CLI without sending your message. Shift + Enter is also bound, but it depends on your terminal — in many terminals it does nothing useful and your half-written prompt gets submitted instead. Ctrl + J works everywhere.

Why Shift+Enter often does nothing

This isn't a Codex bug. Traditional terminals send characters, not key events, and there is no distinct character for "Shift plus Enter" — both plain Enter and Shift + Enter arrive as the same carriage return. Codex has no way to tell them apart, so it does what you asked for by default: it submits.

Modern terminals can opt into a richer protocol that reports modifier keys properly, and in those Shift + Enter works fine. That's why you'll find people online insisting it works — for them, it genuinely does. Ctrl + J sidesteps the whole question, because it is a real control character (a literal line feed) that every terminal has sent unambiguously for fifty years.

How to get a new line, ranked by reliability

ApproachReliabilityWhen to use it
Ctrl + JWorks in every terminalYour default. Build the muscle memory here.
Shift + EnterDepends on the terminalFine if you've confirmed it works in yours.
Ctrl + GAlways worksOpens your $EDITOR. Best for anything longer than a few lines.
Paste multi-line textAlways worksPasting keeps its line breaks — it isn't affected by this at all.

Fixing Shift+Enter in your terminal

If you'd rather have Shift + Enter than learn Ctrl + J, the fix lives in your terminal's settings, not in Codex. The general approach is to bind Shift + Enter to send the same escape sequence that Ctrl + J does:

  • iTerm2 — Settings → Profiles → Keys → add a mapping for Shift + Enter that sends a hex code of 0x0a (line feed).
  • Windows Terminal — add an actions entry in settings.json that sends input \n for the Shift + Enter key chord.
  • VS Code's integrated terminal — VS Code intercepts some chords before the shell sees them. Check terminal.integrated.sendKeybindingsToShell, or just use Ctrl + J, which passes straight through.
  • macOS Terminal.app — no modifier-reporting support to speak of. Use Ctrl + J.
  • tmux — tmux sits between your terminal and Codex and can swallow modifier reporting. Ctrl + J is the reliable choice inside a tmux session.

For anything long, use the editor instead

Once a prompt runs past a few lines, stop fighting the input box. Ctrl + G opens your draft in whatever editor $VISUAL or $EDITOR points at — Vim, VS Code, whatever you use — where you get real editing, real line breaks, and no risk of an accidental submit. Save and close, and the text comes back into Codex ready to send. It's the single most under-used key in the tool.

Related keys people look for at the same time

If you're queueing up a long instruction, two more keys pair with this one. Tab queues a follow-up prompt while Codex is still working, so you don't have to wait for the turn to finish before typing your next thought. And pressing Esc twice on an empty composer walks back to your previous message so you can edit and re-send it — useful when the multi-line prompt you just sent had a typo in it.

Going the other way, Esc interrupts a running task and Ctrl + C exits Codex CLI entirely.

It's different in every other AI CLI

The newline key is one of the least consistent things across terminal agents. Claude Code uses Shift + Enter (with a backslash-then-Enter fallback that works anywhere), Gemini CLI uses Ctrl + J like Codex, and Kimi Code CLI binds both. The full cross-tool comparison maps newline, interrupt, and exit for every agent, and the Codex CLI cheat sheet has the complete keymap in one printable page.