# Codex new line: Ctrl+J in the CLI, and how to stop Enter sending

> Shift+Enter works in the Codex CLI only when your terminal reports it, while the desktop app and IDE extension have a setting that makes Cmd+Enter or Ctrl+Enter the send key.

URL: https://claudegpt.si/news/codex-new-line  
Published: 2026-11-19T10:58:25.943Z  
Author: ClaudeGPT Si Newsroom  
Section: Guides  
Topics: Codex, OpenAI, Codex CLI, How to, Coding agents  
Publisher: ClaudeGPT Si

## 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](https://learn.chatgpt.com/docs/developer-commands?surface=cli) and the source of the open-source [openai/codex](https://github.com/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](https://github.com/openai/codex/blob/main/codex-rs/tui/src/keymap.rs) 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](https://learn.chatgpt.com/docs/cli-customization) 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](https://learn.chatgpt.com/docs/developer-commands?surface=cli) 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:

```toml
[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](https://learn.chatgpt.com/docs/config-file/config-reference) 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](https://learn.chatgpt.com/docs/reference/settings) 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](https://learn.chatgpt.com/docs/reference/commands) 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](https://learn.chatgpt.com/docs/developer-settings?surface=ide) 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](https://learn.chatgpt.com/docs/config-file/config-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.

## Related guides

The same question comes up for other coding tools. See [how to add a new line in Claude Code](https://claudegpt.si/news/claude-code-new-line) and the [Copilot new line guide](https://claudegpt.si/news/copilot-new-line-shift-enter). For another Codex control people look for, see [how to turn Codex plan mode on and off](https://claudegpt.si/news/codex-plan-mode-enter-exit).

## 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

- [Codex CLI commands and interactive shortcuts](https://learn.chatgpt.com/docs/developer-commands?surface=cli), OpenAI
- [CLI customization](https://learn.chatgpt.com/docs/cli-customization), OpenAI
- [Configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference), OpenAI
- [ChatGPT desktop app settings](https://learn.chatgpt.com/docs/reference/settings), OpenAI
- [ChatGPT desktop app commands](https://learn.chatgpt.com/docs/reference/commands), OpenAI
- [Codex IDE extension settings](https://learn.chatgpt.com/docs/developer-settings?surface=ide), OpenAI
- [Codex IDE extension](https://learn.chatgpt.com/docs/codex/ide), OpenAI
- [openai/codex: TUI keymap source (keymap.rs)](https://github.com/openai/codex/blob/main/codex-rs/tui/src/keymap.rs), OpenAI
- [openai/codex: footer shortcut hints (footer.rs)](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/footer.rs), OpenAI
- [openai/codex: paste burst detection (paste_burst.rs)](https://github.com/openai/codex/blob/main/codex-rs/tui/src/bottom_pane/paste_burst.rs), OpenAI
- [openai/codex: composer input widget (composer_input.rs)](https://github.com/openai/codex/blob/main/codex-rs/tui/src/public_widgets/composer_input.rs), OpenAI
