Key takeaways

  • In the Codex CLI, Ctrl+J adds a new line to the prompt and Enter sends it.
  • Shift+Enter and Alt+Enter also add a line in the CLI, but only in terminals that report modified keys to Codex.
  • The Codex desktop app and IDE extension send on Enter by default, and each has a setting that makes Cmd+Enter or Ctrl+Enter the send key.

To add a new line in a Codex prompt without sending it, press Ctrl+J in the Codex CLI. Shift+Enter and Alt+Enter (Option+Enter on a Mac) also add a new line in the CLI, but only in terminals that report modified keys to Codex, so Ctrl+J is the one that works everywhere. In the Codex desktop app and the IDE extension, Enter sends by default, and a setting makes Enter safe for multi-line prompts by requiring Cmd+Enter or Ctrl+Enter to send.

That covers most people who search "codex new line". The rest of this guide shows where each setting lives, how to remap the key in the CLI, and what to do when a new line still sends the prompt. It is based on OpenAI's Codex docs at learn.chatgpt.com and the source of the open-source openai/codex repository, as of November 19, 2026.

Codex new line shortcuts at a glance

Where you type New line Send How to change it
Codex CLI Ctrl+J, or Shift+Enter or Alt+Enter where the terminal supports them Enter /keymap, or tui.keymap in config.toml
Codex in the ChatGPT desktop app Enter, once you require Cmd+Enter or Ctrl+Enter to send Enter by default Settings, General
Codex IDE extension (VS Code, Cursor, Windsurf) Enter, once you set cmdIfMultiline or cmdAlways Enter by default The chatgpt.composerEnterBehavior setting

How to add a new line in Codex CLI

In the terminal client, Enter submits the prompt. The default keymap in OpenAI's keymap source binds the composer's submit action to Enter and the "insert newline" action to Ctrl+J, Ctrl+M, Enter, Shift+Enter and Alt+Enter. When two actions share Enter in the prompt box, submit wins.

To write a prompt on several lines:

  1. Type the first line.
  2. Press Ctrl+J to start a new line. The cursor moves down and nothing is sent.
  3. Keep typing. Press Ctrl+J again for each new line.
  4. Press Enter when the whole prompt is ready.

By default, Ctrl+J is also the key Codex shows for "New line" in its own shortcut hints. Press ? in an empty prompt box to open the shortcut list and check what your session uses.

For long prompts there is a second route. The CLI customization docs say Ctrl+G opens the prompt in the editor set by your VISUAL variable, or EDITOR when VISUAL isn't set. Write as many lines as you want there, then save and close the editor, and the text comes back to the Codex prompt box, ready to send.

Why Shift+Enter sends the prompt in some terminals

Shift+Enter only works when the terminal tells Codex that Shift was held down. Codex checks for that at startup. In the source, a terminal's support for "keyboard enhancement" decides whether the Shift+Enter new line behavior and its hint are turned on. In a terminal that can't report it, Shift+Enter reaches Codex as a plain Enter, and a plain Enter sends the prompt.

So if Shift+Enter submits half-written prompts, nothing is broken in Codex. Use Ctrl+J, or remap the new line key as shown below.

How to remap the new line key in Codex CLI

The CLI lets you change its shortcuts with the /keymap slash command. The slash command reference describes three steps:

  1. Type /keymap in a Codex session.
  2. Pick the shortcut context and the action you want to change. The new line action is insert_newline in the editor context.
  3. Enter the new binding, or remove the existing one.

Codex saves the result under tui.keymap in config.toml. You can also edit that file by hand. Key names are written like ctrl-a, shift-enter and page-down, and an empty list unbinds an action. This is the default list for the new line key, written out in that format:

[tui.keymap.editor]
insert_newline = ["ctrl-j", "ctrl-m", "enter", "shift-enter", "alt-enter"]

One catch from the source: a list you set replaces the built-in one for that action, it doesn't add to it. If you want to keep Ctrl+J as a fallback, keep "ctrl-j" in your list.

The composer's send key lives in a different context. OpenAI's configuration docs show it as submit = ["enter", "ctrl-m"] under [tui.keymap.composer].

How to add a new line in the Codex app

Codex in the ChatGPT desktop app sends a prompt when you press Enter, by default. The app settings page describes a choice under General: keep Enter as the send key, or require Cmd+Enter on macOS or Ctrl+Enter on Windows and Linux, either for multi-line prompts or for every prompt.

To set it:

  1. Open Settings with Cmd+, on macOS or Ctrl+, on Windows.
  2. Go to General.
  3. Pick the option that requires Cmd+Enter or Ctrl+Enter to send.

With the modifier required, Enter no longer sends that prompt, so you can write line breaks freely and send with Cmd+Enter or Ctrl+Enter.

Don't bring the CLI habit to the app. The app's shortcut list binds Cmd+J on macOS and Ctrl+J on Windows and Linux to "Toggle bottom panel" in Codex. Press Cmd+/ or Ctrl+/ in the app to see every shortcut it has.

How to add a new line in the Codex IDE extension

The extension for VS Code, Cursor and Windsurf has its own setting, chatgpt.composerEnterBehavior. The IDE settings reference lists three values:

Value What Enter does
enter (default) Enter always sends.
cmdIfMultiline Cmd+Enter or Ctrl+Enter sends a prompt that has more than one line.
cmdAlways Cmd+Enter or Ctrl+Enter is always needed to send.

To change it:

  1. Open your editor settings.
  2. Search for @ext:openai.chatgpt, Codex or chatgpt.composerEnterBehavior.
  3. Set it to cmdIfMultiline or cmdAlways.

A related key is easy to mix up. Cmd+Shift+Enter or Ctrl+Shift+Enter in the extension doesn't add a line. It flips how one message sent during a run is handled, between waiting for the next run and steering the current one, according to the chatgpt.followUpQueueMode entry in the same reference.

When a new line still sends your Codex prompt

  • Shift+Enter sends in the CLI. Your terminal isn't reporting the Shift key. Use Ctrl+J, or bind another key with /keymap.
  • You changed the keymap and Ctrl+J stopped working. Your insert_newline list replaced the default one. Add "ctrl-j" back to it in config.toml.
  • Pasted text with line breaks gets sent too early. Some terminals, notably on Windows according to the source, deliver a paste as a fast stream of key presses. Codex detects these bursts and treats Enter inside them as a new line. That detection is on by default, and the configuration reference lists tui.disable_paste_burst (default false) as the switch that turns it off. Leave it off unless you have a reason.
  • Enter sends in the app or the IDE extension. That is the default. Change the setting described above for that surface.
  • The prompt is too long to edit comfortably. In the CLI, press Ctrl+G and write it in your editor.

The same question comes up for other coding tools. See how to add a new line in Claude Code and the Copilot new line guide. For another Codex control people look for, see how to turn Codex plan mode on and off.

Frequently asked questions

How do I add a new line in a Codex prompt?

In the Codex CLI, press Ctrl+J. In the Codex desktop app and the IDE extension, change the Enter setting so Cmd+Enter or Ctrl+Enter sends, and Enter is then free for line breaks.

Why does Shift+Enter send my prompt in Codex CLI?

Codex can only see Shift+Enter when the terminal reports the Shift key, which it checks at startup. Otherwise Shift+Enter arrives as a plain Enter, which sends. Use Ctrl+J or remap the key with /keymap.

How do I change the Enter key in the Codex VS Code extension?

Set chatgpt.composerEnterBehavior to cmdIfMultiline, so Cmd+Enter or Ctrl+Enter sends multi-line prompts, or to cmdAlways, so the modifier is always needed. The default, enter, sends on every Enter.

Can I write long Codex prompts in my own editor?

Yes. In the Codex CLI, press Ctrl+G to open the prompt in the editor set by VISUAL or EDITOR. Save and close it to bring the text back to the prompt box.

Sources

  1. Codex CLI commands and interactive shortcutsOpenAI
  2. CLI customizationOpenAI
  3. Configuration referenceOpenAI
  4. ChatGPT desktop app settingsOpenAI
  5. ChatGPT desktop app commandsOpenAI
  6. Codex IDE extension settingsOpenAI
  7. Codex IDE extensionOpenAI
  8. openai/codex: TUI keymap source (keymap.rs)OpenAI
  9. openai/codex: footer shortcut hints (footer.rs)OpenAI
  10. openai/codex: paste burst detection (paste_burst.rs)OpenAI
  11. openai/codex: composer input widget (composer_input.rs)OpenAI

Add ClaudeGPT Si as a preferred source on Google