codex icon indicating copy to clipboard operation
codex copied to clipboard

shift enter newline

Open matssk opened this issue 1 year ago • 21 comments

What feature would you like to see?

It seems shift+enter for newline may have been implemented in the previous typescript version, but now it has been changed to Ctrl+J. Ctrl+J is already a shortcut in vscode and probably other IDEs too.

Are you interested in implementing this feature?

No response

Additional information

No response

matssk avatar Aug 15 '25 19:08 matssk

Shift Enter when in regular terminal Ctrl J when in Tmux

shanecowherd avatar Aug 16 '25 03:08 shanecowherd

Whatever solution ends up being adopted, what's an absolute turn-off is pasting text being unusable: it auto-submits at the first newline character and drops the rest of the text. It's impossible to copy and paste logs onto the terminal.

Zamaroht avatar Aug 16 '25 19:08 Zamaroht

you guys need enable some sort of bracketed paste... we use ctr-j as an alias to ctr-v ctr-j in our software, but a shift-enter would be simpler than ctr-j for most users, i reckon

mountaineerbr avatar Aug 17 '25 02:08 mountaineerbr

Are you all still seeing these issues? I'm on macOS (iTerm) and was able to shift + enter, ctrl + j, and paste multiline text. If so, please share your OS and terminal.

gpeal avatar Aug 23 '25 16:08 gpeal

Can't use shift+enter. vscode with bash terminal on ubuntu in a remote container

matssk avatar Aug 25 '25 18:08 matssk

Hey, @gpeal I'm running the latest MacOS beta + tmux in Ghostty. Outside tmux, shift+enter works normally, but inside a tmux session, only ctrl+j is shown, but I'm already using ctrl+j for moving between panes, so it's a no go for me

Added a 👍 but just wanted to say that I am also in this exact scenario with MacOS stable + tmux in iTerm2.

The solution in claude code is / + Enter to escape the newline. It's not the most intuitive solution in the world, but it works well.

panzacoder avatar Aug 28 '25 16:08 panzacoder

Option+Enter please. macOS Terminal works this way.

m-emelchenkov avatar Aug 29 '25 20:08 m-emelchenkov

Shift + enter, control + enter, or #3049 would be great for me. I'm also running into the issue of Ctrl+J already being an existing, heavily used shortcut in VSCode.

alliepiper avatar Sep 09 '25 13:09 alliepiper

Running codex in tmux in Wezterm on Mac. Shift+Enter runs the command. Cmd+J is my tmux prefix. Would be wonderful not to need to remap just for this.

flowerornament avatar Sep 11 '25 04:09 flowerornament

Yeah, I can't really use ctrl+j in tmux either... Having shift+enter work all the time or let us configure would be nice

A quick fix for now in tmux:

bind -n C-j send-keys C-j

That way tmux forwards Ctrl+J instead of treating it as Enter. However this means you can't go to panes below your codex pane.

idriss-mortadi avatar Sep 12 '25 08:09 idriss-mortadi

Or

# Leader + j sends Ctrl-j to the app
bind j send-keys C-j

idriss-mortadi avatar Sep 12 '25 09:09 idriss-mortadi

As an addition to @idriss-mortadi comment, if you use tmux with the vim-tmux-navigator plugin. You can configure this at the end of your .tmux.conf:


# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.config/tmux/plugins/tpm/tpm'

# Important to put this after the run tpm
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"

unbind -n C-j
bind -n C-j if-shell "$is_vim" { send-keys C-j } { \
    send-keys C-j ; \
    select-pane -D \
}

Apply the changes with tmux source-file .tmux.conf This allows you to use Ctrl+J to do newlines in codex while you can still move to pane below, both in tmux and from neovim. And if you prefer to use Shift+Enter you can configure that key combination to send Ctrl+J in your terminal (e.g., with Wezterm). This is my config as an example:

local wezterm = require 'wezterm'
local config = {}

-- In case you install it in WSL
-- config.default_domain = 'WSL:Ubuntu'

config.enable_tab_bar = false
config.window_decorations = "RESIZE"
config.font = wezterm.font "UbuntuMono Nerd Font"
config.window_background_opacity = 0.81
config.font_size = 18
config.keys = {
  {
    key = 'F11',
    action = wezterm.action.ToggleFullScreen,
  },
  -- This is what you need for using "Shift+Enter" in Codex with Wezterm
  {
    key="Enter",
    mods="SHIFT",
    action=wezterm.action{SendString="\n"}
  },
}

return config

aams-eam avatar Sep 19 '25 18:09 aams-eam

this already works in codex-cli 0.39.0 (test on Mac/iTerm2)

youurayy avatar Sep 23 '25 16:09 youurayy

this already works in codex-cli 0.39.0 (test on Mac/iTerm2)

Opt+Enter works now, good. But Shift+Enter still not.

m-emelchenkov avatar Sep 23 '25 17:09 m-emelchenkov

Still no Shift+Enter in IntelliJ IDEA terminal.

alexeydubinin avatar Sep 26 '25 02:09 alexeydubinin

this already works in codex-cli 0.39.0 (test on Mac/iTerm2)

Opt+Enter works now, good. But Shift+Enter still not.

alright could be a leftover of Claude Code's /terminal-setup -- I have this entry in my iTerm2's "Key Bindings":

Image

youurayy avatar Sep 26 '25 21:09 youurayy

Shift+enter and ctrl+j should both work in the latest versions. Closing this as we haven't seen new reports for a bit and there are plenty of workarounds listed above if you have a particular setup where this happens to unfortunately not work out of the box.

tibo-openai avatar Oct 19 '25 02:10 tibo-openai

@tibo-openai Problem still exists in v0.47.0. In IntelliJ IDEA terminal. (switched to codex from claude and this problem very annoying)

alexeydubinin avatar Oct 20 '25 12:10 alexeydubinin

But they made Alt + Enter work. Have developers ever heard of https://en.wikipedia.org/wiki/Principle_of_least_astonishment !?

I vote for either making it configurable or either Ctrl + Enter or Shift + Enter ( Alt + Enter is first time in my life and I am 34 years with computers).

I am pressing Ctrl + Enter and it start processing partial prompt instead of letting me enter the rest. This is an example how one not very thoughtful decision ruins the entire great product. Or there is a plan to move the entier world to Alt + Enter :)

dmugtasimov avatar Oct 31 '25 11:10 dmugtasimov

If you use vscode ssh from windows to remote linux. Add this to keybindings.json

    {
      "key": "shift+enter",
      "command": "workbench.action.terminal.sendSequence",
      "args": { "text": "\\\n" },
      "when": "terminalFocus"
    }

zzhixin avatar Dec 29 '25 05:12 zzhixin