⌥+⌃AltPlusCtrl

How to Add a Newline in Codex CLI Without Sending (Ctrl+J)

Windows: Ctrl+J
Mac: Ctrl+J
Linux: Ctrl+J
Ctrl+J inserts a line break in the Codex CLI composer without submitting the message. It is identical on macOS, Linux and Windows, because it is a terminal control code rather than an application shortcut. **Why Shift+Enter is unreliable rather than simply wrong.** Shift+Enter is what nearly everyone tries first, and it genuinely works for some people — which is what makes the problem confusing, since two users comparing notes can both be describing their real experience. The cause sits in the terminal, not in Codex. Terminals differ in whether they transmit a distinguishable escape sequence for Shift+Enter at all. In many of them the application receives something indistinguishable from a plain Enter, so the message sends. Some terminals can be configured to send a distinct sequence, which is why the behaviour varies between iTerm2, Windows Terminal, the VS Code integrated terminal, Alacritty, Ghostty and the rest. **Ctrl+J avoids the problem entirely.** It transmits an actual line-feed character, which every terminal passes through unchanged because it is not a modified key combination requiring interpretation — it is one of the original control characters, and its meaning has not varied in decades. That is why it is the binding to commit to memory even if Shift+Enter happens to work on the machine you are using today. **For anything longer, use Ctrl+G instead.** It hands the current composer contents to whatever VISUAL or EDITOR points at and takes back what you save. A prompt with sections, a pasted stack trace and a couple of code examples is genuinely unpleasant to compose in a single-line-oriented input, however you insert the newlines. Your actual editor has search, undo, syntax awareness and a cursor that behaves — and the round trip is one keystroke out and one save back. **Watch out for pasting multi-line text.** Pasting a block that contains newlines into the composer can, depending on the terminal, submit at the first line break rather than inserting the whole block. Terminals with bracketed paste enabled handle this correctly; older or minimally-configured ones may not. If a paste keeps sending prematurely, that is the mechanism, and Ctrl+G is again the reliable route — paste into your editor, save, and the whole block arrives intact. **A note on why this comes up so often.** Prompts for a coding agent tend to be long and structured in a way that chat messages are not: context, then a task, then constraints, then an example. That structure wants line breaks. A composer that submits on Enter is the right default for conversational use and the wrong one for the way people actually write agent prompts, which is why 'how do I add a newline' is among the first things almost every Codex CLI user searches for. **If Ctrl+J appears to do nothing**, the likely cause is that something between you and Codex is intercepting it. Some terminal multiplexers and remote-session tools claim control characters for their own bindings, and tmux in particular is worth checking since its default prefix and several of its bindings live in the same space. Running Codex outside the multiplexer briefly will tell you quickly whether that is the explanation.

Related shortcuts