In Claude Code, Shift+Enter sends a half-written prompt instead of adding a line break: why, and which inputs always insert a newline?
answer
- the terminal decides what arrives
- two keys that never need setup
- backslash before Enter
- /terminal-setup for editor terminals
- tmux needs extended keys
basics
~20 sMany terminals send Shift+Enter as a plain Enter, so Claude Code submits. Ctrl+J and a backslash followed by Enter insert a newline in every terminal; /terminal-setup or tmux extended keys make Shift+Enter work where supported.
solid answer
~30 s`Enter` submits, and Claude Code only sees what the terminal sends; many terminals send the same bytes for `Shift+Enter` as for `Enter`. `Ctrl+J` (the `chat:newline` action) and `\` followed by `Enter` work in every terminal with no setup, and pasted text keeps its line breaks. `Shift+Enter` works natively in iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal and Windows Terminal; VS Code, Cursor and Zed need `/terminal-setup` once, gnome-terminal and JetBrains terminals cannot do it, and inside tmux it submits until extended keys are enabled. For long prompts, `Ctrl+G` opens the draft in your text editor.
go deeper
Recall the two newline inputs that work everywhere, Ctrl+J and a backslash before Enter, and that pasting keeps line breaks.
Explain why Shift+Enter fails: the terminal sends plain Enter. Know which terminals need /terminal-setup and that tmux needs extended keys.
Diagnose a teammate's setup quickly across terminal, multiplexer and keybindings layers, and steer long prompts to Ctrl+G instead of fighting the input box.
When standardising a team's environment, decide whether to document Ctrl+J as the universal key or invest in terminal configuration, given the editors and multiplexers people actually use.
## Why Enter is the problem In the Claude Code prompt, **`Enter` submits**. Writing a prompt that spans several lines (a numbered plan, a stack trace with a question under it, acceptance criteria) therefore needs a key that inserts a line break instead. The catch is that a terminal application only sees the bytes the terminal emulator sends. Many terminals send exactly the same thing for `Shift+Enter` as for `Enter`, so Claude Code cannot tell them apart and submits. ## The inputs that always work Two methods work **in every terminal with no setup**: 1. **`\` then `Enter`** (the "quick escape"): type a backslash at the end of the line and press `Enter`. 2. **`Ctrl+J`**: the control sequence for a line feed, bound to the `chat:newline` action by default. A third route is **pasting**: multi-line text pasted into the prompt keeps its line breaks, which is the natural way to bring in code blocks and logs. ## When `Shift+Enter` works | Terminal | `Shift+Enter` for a newline | | :- | :- | | iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal, Windows Terminal | Works without setup | | Other terminals that speak the kitty keyboard protocol (such as foot, newer Alacritty) | Works without setup on recent releases | | VS Code, Cursor, Zed, older Alacritty | Run `/terminal-setup` once | | gnome-terminal, JetBrains IDE terminals | Not available: use `Ctrl+J` or `\` + `Enter` | - **`/terminal-setup`** writes a `Shift+Enter` keybinding into the terminal's own configuration (for VS Code and Cursor it also adjusts a couple of integrated-terminal settings). Existing bindings are left in place. - **tmux** is its own layer: inside tmux, `Shift+Enter` submits by default **even when the outer terminal supports it**, until `~/.tmux.conf` enables extended keys so tmux can pass the distinction through. - **macOS `Option+Enter`** inserts a newline once Option is configured as Meta in the terminal. ## Long prompts: the external editor For anything longer than a few lines, editing in the prompt box gets awkward. `Ctrl+G` (or the readline-style `Ctrl+X Ctrl+E`) opens the current prompt in your **default text editor**; save and close, and the text comes back to the prompt ready to send. Turning on **Show last response in external editor** in `/config` prepends Claude's previous reply as `#`-commented context above your prompt, and Claude Code strips that comment block when you save. Other keys that help with long drafts: - **`Ctrl+S`** stashes the current draft and clears the prompt; pressed again on an empty prompt it restores it. - **`Ctrl+R`** searches your prompt history, so a long prompt you sent last week can be recalled and edited instead of retyped. - **`Ctrl+_`** undoes the last input edit. ## Changing the keys themselves If your hands expect `Enter` to insert a newline and a modifier to send, map the `chat:newline` and `chat:submit` actions in `~/.claude/keybindings.json` (opened with `/keybindings`). That swaps the behaviour inside Claude Code, but it cannot make a terminal send a distinct `Shift+Enter` if the terminal does not; that part is still `/terminal-setup` or the terminal's own configuration. ## Diagnosing "Shift+Enter sends my half-written prompt" 1. Check whether the terminal is on the "works without setup" list; if not, run `/terminal-setup`, or fall back to `Ctrl+J`. 2. If you are inside tmux, add the extended-keys configuration and reload tmux. 3. In a terminal where it cannot work, use `Ctrl+J`, `\` + `Enter`, or `Ctrl+G` for long text.
- Can you make Enter insert a newline and a modified key submit instead?Yes: map the `chat:newline` and `chat:submit` actions in `~/.claude/keybindings.json`, which `/keybindings` creates or opens. Remapping changes what Claude Code does with a key, but it cannot make a terminal report `Shift+Enter` separately if the terminal does not send it.
- Shift+Enter works the same in every terminal because Claude Code handles it.
- Nothing but Shift+Enter can add a line break to a Claude Code prompt.
- Inside tmux, Shift+Enter works whenever the outer terminal supports it.
- Ctrl+J submits the prompt, the same as Enter.
- Enter always submits and no setting can change that.