You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codex TUI prompt Feature: Shift+Enter to support newline in codex interactive prompt #8673
Support Shift+Enter to insert a newline in the interactive TUI prompt (multi‑line input without submitting).
Proposal :
Keybinding Shift+Enter should insert a newline. At the same time, when there is no text/prompt in the codex interactive TUI, it should disable Shift+Enter to avoid accidental blank lines; spacing tokenization percentage cost.
Problem :
As of now, when users wanna enter newline with Shift+Enter, it's just prompting to AI Codex, not going to newline. This could be annoyance to users with large prompt willing to go to next new line.
Additional information
Demo of Shift+Enter not entering new line. :)
trim.2B14A6B1-7766-4F2C-98C8-83FD18DB92B3.MOV
Reacted by Fabio Andres Espinosa Valcarcel, welschmoor, Arne, Braham Snyder, Aung Nanda Oo, Stephen Anindo, Miro Keimiöniemi and Chris Pick
changed the title [-]Codex TUI prompt Feature: Shift+Enter newline in interactive prompt[/-][+]Codex TUI prompt Feature: Shift+Enter to support newline in codex interactive prompt[/+]on Jan 2, 2026
Codex needs to run in many different terminal emulators and across multiple platforms. Earlier versions of Codex supported Shift+Enter, but this caused problems with many terminal emulators. After investigating potential solutions, we switched to Ctrl+J as the key binding for entering newlines. This works across all terminals and platforms.
Reacted by Ildar Sagdejev and Olexi Potapov
Reacted by shanesparfuchs, Adam, Gage Vander Clay, Jaden Tripp, Ethan Joseph, Casey Siebel, Richard Rose and Simon Spettmann
Reacted by Fabio Andres Espinosa Valcarcel, Aung Nanda Oo, Robin | Liquidium, Mark Hemmings, ruiny, Florent Biville, Andy D. Nguyen, Tarek shawesh, Braham Snyder, shanesparfuchs and 7 more
Codex needs to run in many different terminal emulators and across multiple platforms. Earlier versions of Codex supported Shift+Enter, but this caused problems with many terminal emulators. After investigating potential solutions, we switched to Ctrl+J as the key binding for entering newlines. This works across all terminals and platforms.
That's fair enough, keep Ctrl+J as the default.
Please add the option to change newline to Shift + Enter for those of us who's terminals emulators allow us to do that.
Reacted by Soeren Apel, Alexey Sokolov, Richard Donkin, Kaur Kuut, Florent Biville, Souvik Biswas, shanesparfuchs, Jaden Tripp, Aung Nanda Oo, A Mennucc and 1 more
If supporting Shift+Enter is difficult, then please consider Option+Enter or Command+Shift+Enter instead. Ctrl+J is a really poor choice.
What happens if, for some reason, the same developer ends up using Codex on both Ubuntu and macOS in the future?
At the very least, Command+J would be a better option.
The Ctrl key is disliked by many macOS users :)
I just paid for the subscription. I can't believe this is the key binding! ctrl+j for me is down arrow because of vim bindings. who chooses these things?
Reacted by shanesparfuchs, Aung Nanda Oo and Peter Tu
Quick note from a deeper dive on the Windows Terminal angle of this — there's a Windows-specific manifestation that's slightly different from what's been discussed.
I ran crossterm's key-event capture on Windows Terminal pressing Shift+Enter, plain Enter, Ctrl+J, Ctrl+M, and Ctrl+Enter. Result:
Keypress
crossterm event
Shift+Enter
KeyCode::Enter + CONTROL
Ctrl+Enter
KeyCode::Enter + CONTROL ← identical
Plain Enter
KeyCode::Enter (no mods)
Ctrl+J
KeyCode::Char('j') + CONTROL
Ctrl+M
KeyCode::Char('m') + CONTROL
Two takeaways:
Windows Terminal collapses Shift+Enter and Ctrl+Enter into the same event at the OS console layer. That's a Windows console limitation, can't be undone from codex's side.
None of the existing insert_newline defaults match KeyCode::Enter + CONTROL — defaults check Char('j')+CTRL, Char('m')+CTRL, plain Enter, shift Enter, alt Enter. So the actual event Windows Terminal delivers matches none of them, and the keystroke either submits (via composer's submit_keys) or gets eaten depending on context.
This explains why the ~/.codex/config.toml workaround circulating in #4218 and elsewhere (insert_newline = ["ctrl-j", "ctrl-m", "enter", "shift-enter", "alt-enter"]) doesn't reliably help on Windows Terminal: it's identical to the defaults. None of the bindings in that list catch the actual Enter+CONTROL event.
@joshka-oai's observation in #3024 is exactly right — many terminals collapse Shift+Enter into other signals. Ctrl+J is the official cross-platform answer. This patch is consistent with that pattern; it just adds Enter+CONTROL (Windows Terminal's collapsed event) to the same set that Ctrl+J already lives in.
Add ctrl(KeyCode::Enter) to editor.insert_newline defaults under #[cfg(windows)]. Catches both Shift+Enter and Ctrl+Enter on Windows Terminal (they're indistinguishable anyway). Linux/macOS unchanged — shift(KeyCode::Enter) already handles those via the kitty protocol.
Windows Terminal: even with kitty protocol enabled, Shift+Enter is delivered as Enter+CTRL (Windows console quirk). My branch above addresses this one.
Happy to open a PR per CONTRIBUTING.md if a maintainer wants to invite. Otherwise the branch is public and the diff is small enough to be picked up under another author if that fits the workflow better.
The keybinding for this action is now editable. You can use /keymap to assign whatever keybinding you prefer. This allows you to select a binding that's compatible with your terminal emulator.
Reacted by Serge Baranov and Aung Nanda Oo
Reacted by Serge Baranov and Aung Nanda Oo
Reacted by Serge Baranov, Drew Bailey and Aung Nanda Oo
Activity
[-]Codex TUI prompt Feature: Shift+Enter newline in interactive prompt[/-][+]Codex TUI prompt Feature: Shift+Enter to support newline in codex interactive prompt[/+]NikkiAung commentedon Jan 2, 2026
@etraut-openai, feel free to lmk about my proposal! Im super excited to contribute! :)
etraut-openai commentedon Jan 2, 2026
Codex needs to run in many different terminal emulators and across multiple platforms. Earlier versions of Codex supported Shift+Enter, but this caused problems with many terminal emulators. After investigating potential solutions, we switched to Ctrl+J as the key binding for entering newlines. This works across all terminals and platforms.
SocialNerd42069 commentedon Jan 3, 2026
bring back shift + enter! ctrl+j is annoying
NikkiAung commentedon Jan 7, 2026
Also feeling the same way, but this also applied in Claude Code CLI. Hopefully, they would bring back in future! :))
Lmk what u guys think of the below feat as well, @SocialNerd42069 and @faev999!
#8709
robin-liquidium commentedon Jan 20, 2026
we should at least be able to choose between the two (or have both ideally). maybe allowing for custom keybindings would help a lot here.
shift+enteris also still highlighted as the command still when using?to show the shortcuts (using TUI2).louisprince commentedon Feb 19, 2026
That's fair enough, keep Ctrl+J as the default.
Please add the option to change newline to Shift + Enter for those of us who's terminals emulators allow us to do that.
Rockio-sy commentedon Apr 25, 2026
Avoid Control Button Please!
If supporting Shift+Enter is difficult, then please consider Option+Enter or Command+Shift+Enter instead. Ctrl+J is a really poor choice.
What happens if, for some reason, the same developer ends up using Codex on both Ubuntu and macOS in the future?
At the very least, Command+J would be a better option.
The Ctrl key is disliked by many macOS users :)
rzalawad commentedon May 4, 2026
I just paid for the subscription. I can't believe this is the key binding! ctrl+j for me is down arrow because of vim bindings. who chooses these things?
drewbailey commentedon May 4, 2026
@etraut-openai please make this mappable.. ctrl-j is not tmux friendly
The1Percent commentedon May 5, 2026
Can we please just get back shift+enter? Or make the broken terminals fix it via /keymap? Why break most of your existing users?
jadentripp commentedon May 7, 2026
It would be great if this was configurable in
config.toml.peter-tu-zynkr commentedon May 9, 2026
Ctrl+J is very counter intuitive, at least consider Ctrl+Enter
jacobhallgren commentedon May 10, 2026
Quick note from a deeper dive on the Windows Terminal angle of this — there's a Windows-specific manifestation that's slightly different from what's been discussed.
I ran
crossterm's key-event capture on Windows Terminal pressing Shift+Enter, plain Enter, Ctrl+J, Ctrl+M, and Ctrl+Enter. Result:KeyCode::Enter + CONTROLKeyCode::Enter + CONTROL← identicalKeyCode::Enter(no mods)KeyCode::Char('j') + CONTROLKeyCode::Char('m') + CONTROLTwo takeaways:
insert_newlinedefaults matchKeyCode::Enter + CONTROL— defaults checkChar('j')+CTRL,Char('m')+CTRL,plain Enter,shift Enter,alt Enter. So the actual event Windows Terminal delivers matches none of them, and the keystroke either submits (via composer'ssubmit_keys) or gets eaten depending on context.This explains why the
~/.codex/config.tomlworkaround circulating in #4218 and elsewhere (insert_newline = ["ctrl-j", "ctrl-m", "enter", "shift-enter", "alt-enter"]) doesn't reliably help on Windows Terminal: it's identical to the defaults. None of the bindings in that list catch the actualEnter+CONTROLevent.@joshka-oai's observation in #3024 is exactly right — many terminals collapse Shift+Enter into other signals.Ctrl+Jis the official cross-platform answer. This patch is consistent with that pattern; it just addsEnter+CONTROL(Windows Terminal's collapsed event) to the same set thatCtrl+Jalready lives in.Proposed fix
Branch: https://github.com/jacobhallgren/codex/tree/fix/win-shift-enter
codex-rs/tui/src/keymap.rs:ctrl(KeyCode::Enter)toeditor.insert_newlinedefaults under#[cfg(windows)]. Catches both Shift+Enter and Ctrl+Enter on Windows Terminal (they're indistinguishable anyway). Linux/macOS unchanged —shift(KeyCode::Enter)already handles those via the kitty protocol.validate_no_shadowallowed_overlapslist with the same key/action pair, so users who rebindcomposer.submit = ctrl-enter(per Config option that swaps the default Enter key behavior: Enter inserts newline, Ctrl+Enter submits input #5716) still pass the runtime conflict check. This mirrors the existing entry that already permitsplain Enterto live in bothcomposer.submitandeditor.insert_newline.Diff size: 1 file, 59 insertions, 22 deletions. Targeted tests pass:
cargo test -p codex-tui --lib keymap(95/95).On the broader picture
This is one of (at least) three different platform-specific manifestations of the same surface symptom; each needs its own targeted fix:
shift(KeyCode::Enter)matches. ✓modifyOtherKeysmode 2 (\x1b[>4;2m), so tmux strips the SHIFT modifier. See the analysis at Shift+Enter is not recognized inside tmux because Codex does not enable modifyOtherKeys / Ext 2 #21699 —@fcoury-oaimentioned a fix is in flight there.Enter+CTRL(Windows console quirk). My branch above addresses this one.Happy to open a PR per CONTRIBUTING.md if a maintainer wants to invite. Otherwise the branch is public and the diff is small enough to be picked up under another author if that fits the workflow better.
etraut-openai commentedon Jul 21, 2026
The keybinding for this action is now editable. You can use
/keymapto assign whatever keybinding you prefer. This allows you to select a binding that's compatible with your terminal emulator.fix(tui): bind Ctrl+Enter to insert_newline so Shift+Enter works on W…