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

Shift+Enter Line Break Fails in VSCode Claude Extension on macOS

Open vzegna opened this issue 6 months ago • 6 comments

Bug Description I cannot find a way to go new line with shift+enter in VSC on Mac. I tried everything. I obviously ran the /terminal-setup command. The only way to go new line in claude in VSC is alt+enter. However, if I use claude in PyCharm or iTerm2, shift+enter works totally fine.

Environment Info

  • Platform: macos
  • Terminal: vscode
  • Version: 1.0.16
  • Feedback ID: f675a831-df8a-4243-8b15-5e50a0269265

Errors

[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n    at genericNodeError (node:internal/errors:983:15)\n    at wrappedFn (node:internal/errors:537:14)\n    at checkExecSyncError (node:child_process:882:11)\n    at execSync (node:child_process:954:15)\n    at WZ (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:654:3921)\n    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:11794\n    at Q (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:17190)\n    at pJ (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:10940)\n    at iP (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:10021)\n    at n6 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:14133)","timestamp":"2025-06-06T17:14:47.392Z"}]

vzegna avatar Jun 06 '25 17:06 vzegna

When using CC from the command line I use \ + ENTER. Not sure if that helps but putting out there. (That was a backslash)

michael-hedgineer avatar Jun 06 '25 17:06 michael-hedgineer

👍 I am experiencing the same issue.

hwrd avatar Jun 09 '25 16:06 hwrd

I was having the same issue and ran /terminal-setup to resolve it

rosshambrick avatar Jun 12 '25 14:06 rosshambrick

I have the same issue.

I ran /terminal-setup, which gave me Found existing VSCode terminal Shift+Enter key binding. Remove it to continue..

I removed it, before re-running /terminal-setup. This gave me Installed VSCode terminal Shift+Enter key binding and created

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

in my keybindings.json file, but it did not solve the issue.

FYI, I'm not using the VSCode's integrated terminal. The problem arises with both zsh (with powerlevel10k and oh-my-zsh) and bash (vanilla). I'm using Claude Code 1.0.35.


Let me add that after /terminal-setup added

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

to the keybindings.json, re-running it raises Found existing VSCode terminal Shift+Enter key binding. Remove it to continue., which does suggest there's an issue.

itsmevictor avatar Jun 26 '25 10:06 itsmevictor

Same problem for me! The /terminal-setup command does not fix it. It just keeps adding the key binding, then saying to remove it, then adding it, then saying to remove it..... forever. Typing \enter is terribly unintuitive and prone to error. I just want to type shift+enter like many other typing interfaces, please!

JuliaBonita avatar Jun 30 '25 23:06 JuliaBonita

I found the settings.json line that was causing the issue:

"terminal.integrated.sendKeybindingsToShell": true,

Remove this, and you should be good to go.

vzegna avatar Jun 30 '25 23:06 vzegna

@vzegna Thanks for the suggestion! Didn't work for me.

itsmevictor avatar Jul 01 '25 07:07 itsmevictor

@vzegna Thanks, but that setting was already removed from my VSCode settings and the problem still persists. Hopefully there is another solution coming from the Claude Code team.

JuliaBonita avatar Jul 01 '25 09:07 JuliaBonita

The only alternative solution is the following, but it's a BRUTE FORCE approach:

  • Close VSCode
  • Go into ~/Library/Application Support/Code and rename the Code folder to Code.bak. This will reset all the VSC settings, forcing VSC to create a new Code folder. Your old settings will be preserved in Code.bak in case you wanna revert this change.
  • Open VSC, you will be presented with a brand-new VSC, as if you just downloaded it and installed it.
  • Turn on Sync if you use this feature, and merge the remote settings into the current user settings.

You will probably have to reset things like the Color Theme, font sizes and so on, but this process fixed the issue for me. I am now able to go to a new line in Claude (and in the Terminal in general) by using either Shift+Enter and Option+Enter.

vzegna avatar Jul 01 '25 12:07 vzegna

@vzegna That doesn't work for all systems. I spent a ridiculous amount of time on this. I use Mac and WSL2 and the only thing that actually works across all platforms is adding the following to VSC's keybindings.json file:

// Rule 1: Prevent conflicting commands from running.
    {
        "key": "shift+enter",
        "command": "-workbench.action.terminal.runSelectedText",
        "when": "terminalFocus && !terminalTextSelected"
    },
    // Rule 2: Send the shell's line-continuation syntax.
    {
        "key": "shift+enter",
        "command": "workbench.action.terminal.sendSequence",
        "args": {
            // Send a literal backslash (\\) and a newline (\n).
            "text": "\\\n"
        },
        "when": "terminalFocus"
    }

On WSL2, something completely blocks all attempts to modify the key bindings using bind or any other system tools. I tried many different approaches, but the two JSON objects above are the only thing that worked.

JuliaBonita avatar Jul 01 '25 19:07 JuliaBonita

I found the settings.json line that was causing the issue:

"terminal.integrated.sendKeybindingsToShell": true,

Remove this, and you should be good to go.

This worked for me. Thanks!

Tim-Siu avatar Jul 20 '25 09:07 Tim-Siu

If anyone is using VS Code - Insiders build, this may save them some grief. I was experiencing the same issue as described:

  • I ran /terminal-setup in Claude Code from a VS Code terminal.
  • Claude Code said it created ~/Library/Application\ Support/Code/User/keybindings.json.
  • So I was surprised that Shift-Enter seemed to just execute an 'Enter' within a Claude Code session and in any Terminal session, for that matter.

Solution

After debugging with "Developer: Toggle Keyboard Shortcuts Troubleshooting" I saw that Shift-Enter wasn't matching any 'when' clauses. When I used "Preferences: Open Keyboard Shortcuts (JSON)" I was surprised to see that the file was empty other than the generic header.

Only then did I realize I was looking at the Insiders Build config ~/Library/Application\ Support/Code\ -\ Insiders/User/keybindings.json!

It turns out that Claude should have written to ~/Library/Application\ Support/Code\ -\ Insiders/User/keybindings.json. It didn't realize that I was using VS Code - Insiders. So it wrote to ~/Library/Application\ Support/Code/User/keybindings.json. But this had no effect for me, running Insiders.

Copying the rule into the Insiders Build config file works!

It would be nice if Claude Code would detect itself running from within the Insiders Build and install to the right path.

gwtaylor avatar Jul 28 '25 21:07 gwtaylor

I found the settings.json line that was causing the issue:

"terminal.integrated.sendKeybindingsToShell": true,

Remove this, and you should be good to go.

This worked for me. Thanks!

This works for me as well, I removed this setting from ~/Library/Application Support/Code/User/settings.json and it started working. Just for sake of completeness, the ~/Library/Application Support/Code/User/keybindings.json looks like this:

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

vzegna avatar Aug 08 '25 15:08 vzegna

I found the settings.json line that was causing the issue:

"terminal.integrated.sendKeybindingsToShell": true,

Remove this, and you should be good to go.

oh my god thank you did i've been having this issue for MONTHS!

rublev avatar Sep 03 '25 18:09 rublev

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

Use this, it doesn't trail backslash

toy-crane avatar Sep 15 '25 05:09 toy-crane

Funnily Opt + Enter works

b3nk3 avatar Sep 17 '25 17:09 b3nk3

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 06 '25 10:12 github-actions[bot]