claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] /terminal-setup not working, no way to enter multiple lines

Open empz opened this issue 6 months ago • 14 comments

Environment

  • Claude CLI version: 1.0.3 (Claude Code)
  • Operating System: Windows 11 with WSL2 (Ubuntu)
  • Terminal: Windows Terminal / Bash

Bug Description

I'm using the VS Code extension in VS Code on WSL (Windows 11). I've run /terminal-setup, the keybindings.json contains the following:

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

Still, when I press Shift+Enter, the message is submitted immediately. No way to enter multiple lines...

empz avatar May 27 '25 08:05 empz

Try this " \n" (space important)

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

terminal apps often ignore or misinterpret a bare newline, especially if it looks like empty input.. Likely due to how (PTY) interprets the sequence compared to actual keystrokes

In short, the space ensures the terminal treats the input as meaningful

jopeter avatar May 28 '25 21:05 jopeter

Try this " \n" (space important)

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

terminal apps often ignore or misinterpret a bare newline, especially if it looks like empty input.. Likely due to how (PTY) interprets the sequence compared to actual keystrokes

In short, the space ensures the terminal treats the input as meaningful

Nope, still doesn't work.

empz avatar May 29 '25 08:05 empz

  1. Enable Keybinding Debug Logging Ctrl+Shift+P --> Developer: Toggle Keyboard Shortcuts Troubleshooting This will open Output tab..

  2. Make sure 'Window' (or in some versions: 'Keybinding Troubleshooting') is selected in the output panel dropdown. You'll find this dropdown just above the log area. In most setups (especially with WSL), the log entries will appear under the 'Window' source.

  3. Go to Claude Code input and press 'Shift+Enter'

  4. check Output -->

Scenario 1

Invoking command workbench.action.terminal.sendSequence.
Resolving shift+Enter
From x keybinding entries, matched workbench.action.terminal.sendSequence, when: terminalFocus, source: user.

If above is true but nothing happens --> your keybindings.json is correct and possible 3rd-party extension or other collision is intercepting the keybinding.

Try disable all extensions to rule this out code --disable-extensions

Scenario 2

Resolving shift+Enter
From x keybinding entries, no matching command found.

This suggests that your keybinding probably is incorrectly defined in keybindings.json, placed in the wrong context, or overridden by another command with higher priority.

jopeter avatar May 29 '25 16:05 jopeter

  1. Enable Keybinding Debug Logging Ctrl+Shift+P --> Developer: Toggle Keyboard Shortcuts Troubleshooting This will open Output tab..
  2. Make sure 'Window' (or in some versions: 'Keybinding Troubleshooting') is selected in the output panel dropdown. You'll find this dropdown just above the log area. In most setups (especially with WSL), the log entries will appear under the 'Window' source.
  3. Go to Claude Code input and press 'Shift+Enter'
  4. check Output -->

Scenario 1

Invoking command workbench.action.terminal.sendSequence.
Resolving shift+Enter
From x keybinding entries, matched workbench.action.terminal.sendSequence, when: terminalFocus, source: user.

If above is true but nothing happens --> your keybindings.json is correct and possible 3rd-party extension or other collision is intercepting the keybinding.

Try disable all extensions to rule this out code --disable-extensions

Scenario 2

Resolving shift+Enter
From x keybinding entries, no matching command found.

This suggests that your keybinding probably is incorrectly defined in keybindings.json, placed in the wrong context, or overridden by another command with higher priority.

This is what I get in the output when I press Shift+Enter

2025-05-29 19:02:04.180 [info] [Window] [KeybindingService]: / Soft dispatching keyboard event
2025-05-29 19:02:04.180 [info] [Window] [KeybindingService]: \ Keyboard event cannot be dispatched
2025-05-29 19:02:04.180 [info] [Window] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: ShiftLeft, keyCode: 16, key: Shift
2025-05-29 19:02:04.180 [info] [Window] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: ShiftLeft, keyCode: 4 ('Shift')
2025-05-29 19:02:04.180 [info] [Window] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2025-05-29 19:02:04.464 [info] [Window] [KeybindingService]: / Soft dispatching keyboard event
2025-05-29 19:02:04.465 [info] [Window] [KeybindingService]: | Resolving shift+Enter
2025-05-29 19:02:04.465 [info] [Window] [KeybindingService]: \ From 11 keybinding entries, no when clauses matched the context.
2025-05-29 19:02:04.604 [info] [Window] [KeybindingService]: / Soft dispatching keyboard event
2025-05-29 19:02:04.604 [info] [Window] [KeybindingService]: | Resolving shift+Enter
2025-05-29 19:02:04.604 [info] [Window] [KeybindingService]: \ From 11 keybinding entries, no when clauses matched the context.
2025-05-29 19:02:04.924 [info] [Window] [KeybindingService]: / Soft dispatching keyboard event
2025-05-29 19:02:04.925 [info] [Window] [KeybindingService]: \ Keyboard event cannot be dispatched
2025-05-29 19:02:04.925 [info] [Window] [KeybindingService]: + Ignoring single modifier shift due to it being pressed together with other keys.

I've tried it in an empty profile with just the Claude Code extension. Same thing. Image

If it serves any purpose, from my Ubuntu shell inside Windows Terminal (outside VS Code), I need to press Ctrl+Enter to make a new line, Shift+Enter here also submits the message.

empz avatar May 29 '25 17:05 empz

Also, the /ide command shows "No available IDEs detected".

Image

empz avatar May 29 '25 17:05 empz

Thanks, very useful

Try broader -->

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

However, consider switching 'editor-area terminal' to terminal Since /ide shows "Not detected..." you prob. get better integration by running Claude Code directly in terminal:

Image

jopeter avatar May 29 '25 17:05 jopeter

Thanks, very useful

Try broader -->

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

However, consider switching 'editor-area terminal' to terminal Since /ide shows "Not detected..." you prob. get better integration by running Claude Code directly in terminal:

Image

I've just upgraded to 1.0.6 and the IDE connection is working. Still no way to enter multiple lines... Tried your last suggestion. Also tried launching claude directly from the VS Code terminal instead of by clicking the Claude logo (which seems to be doing just that, launching claude from my default terminal)

empz avatar May 29 '25 17:05 empz

Thanks, very useful Try broader -->

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

However, consider switching 'editor-area terminal' to terminal Since /ide shows "Not detected..." you prob. get better integration by running Claude Code directly in terminal: Image

I've just upgraded to 1.0.6 and the IDE connection is working. Still no way to enter multiple lines... Tried your last suggestion. Also tried launching claude directly from the VS Code terminal instead of by clicking the Claude logo (which seems to be doing just that, launching claude from my default terminal)

Did you also try below when swithed to terminal?

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

Your setup might be unnecessarily complex Try working entirely within WSL-connected VSCode instead of launching it from external terminal.

Connect directly to WSL in VSCode: Ctrl+Shift+P → "WSL: Connect to WSL" Or click WSL indicator in status bar Open your project folder directly in WSL-connected VSCode Use Claude Code extension there - no need for terminal launching

jopeter avatar May 29 '25 18:05 jopeter

Thanks, very useful Try broader -->

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

However, consider switching 'editor-area terminal' to terminal Since /ide shows "Not detected..." you prob. get better integration by running Claude Code directly in terminal: Image

I've just upgraded to 1.0.6 and the IDE connection is working. Still no way to enter multiple lines... Tried your last suggestion. Also tried launching claude directly from the VS Code terminal instead of by clicking the Claude logo (which seems to be doing just that, launching claude from my default terminal)

Did you also try below when swithed to terminal?

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

Your setup might be unnecessarily complex Try working entirely within WSL-connected VSCode instead of launching it from external terminal.

Connect directly to WSL in VSCode: Ctrl+Shift+P → "WSL: Connect to WSL" Or click WSL indicator in status bar Open your project folder directly in WSL-connected VSCode Use Claude Code extension there - no need for terminal launching

Yes, I've tried that.

My setup is not necessarily complex. It's just a clean Ubuntu LTS via WSL2 on Windows because Claude Code won't run on Windows. I'm actually switching to work within WSL just to use Claude Code so, really, I've barely did anything with this WSL instance, it's pretty clean.

Would love someone with Windows 11 + Ubuntu via WSL2 to confirm they can input multi-line commands.

empz avatar May 29 '25 18:05 empz

I only mentioned that multi-line works when using Windows Terminal instead of VS Code integrated terminal, to see if that helped troubleshoot the issue.

empz avatar May 29 '25 18:05 empz

Well, I've just discovered that pressing Alt+Enter does work. Not ideal as I'm not used to it, but okay.

empz avatar May 29 '25 18:05 empz

Well, I've just discovered that pressing Alt+Enter does work. Not ideal as I'm not used to it, but okay.

At least something, i have a similar setup and shift+enter is working just fine for me with " \n"

setup:

  • VSCode: 1.100.2
  • Windows 11 + WSL2 (Ubuntu)
{
  "key": "shift+enter",
  "command": "workbench.action.terminal.sendSequence",
  "args": { "text": " \n" },
  "when": "terminalFocus"
}

Also worth trying to open vscode without terminal launch and then connect with WSL direct connection (Ctrl+Shift+P → "WSL: Connect to WSL") (if you're currently launching VSCode from terminal) sometimes mixing different connection methods can affect.

jopeter avatar May 29 '25 18:05 jopeter

I had the same issue. It seems that VS Code is not picking up keybindings.json in WSL's user directory. I just placed the binding in C:/Users/<user>/AppData/Roaming/Code/User/keybindings.json and it works immediately.

baseltaleb avatar Jun 07 '25 12:06 baseltaleb

I had the same issue. It seems that VS Code is not picking up keybindings.json in WSL's user directory. I just placed the binding in C:/Users/<user>/AppData/Roaming/Code/User/keybindings.json and it works immediately.

Oh wow, that actually makes a lot of sense since the VS Code UI runs on Windows, not WSL. It works that way, thank you!

empz avatar Jun 07 '25 12:06 empz

This worked for me: \ + Enter.

Goldwaterfung avatar Aug 05 '25 12:08 Goldwaterfung

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 13 '25 14:08 github-actions[bot]