claude-code
claude-code copied to clipboard
[BUG] Shift+Enter Does Not Insert New Line in WSL on Windows 10
Environment Platform (select one):
Anthropic API
AWS Bedrock
Google Vertex AI
Other: Claude CLI
Claude CLI version: 1.0.2 (Claude Code)
Operating System: Windows 10 (10.0.19045.3803)
Terminal: Windows Terminal (WSL)
WSL version: 2.4.13.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
Shell: bash
Bug Description Pressing Shift+Enter inside Claude CLI running in WSL on Windows 10 does not insert a new line. Instead, it behaves the same as pressing Enter, which prematurely submits the current input. This prevents users from writing multiline prompts or code blocks.
Steps to Reproduce Open Claude CLI (claude) in WSL (bash shell) using Windows Terminal
Start typing a multiline prompt or code
Press Shift+Enter expecting a newline
Input is submitted instead of moving to the next line
Expected Behavior Shift+Enter should insert a new line, allowing users to write properly formatted multiline input without submitting prematurely.
Actual Behavior Shift+Enter submits the input, just like Enter, making multiline prompts impossible.
Additional Context This affects productivity when writing structured prompts or code snippets. Reproducible consistently on a clean WSL 2 environment with Windows 10. Would be helpful to support standard multiline input behavior.
Same issue, very annoying. Makes it hard to talk to Claude. Also loving the extension, thanks team
@sap2me I'm using their recommendation \ + return in order to add new lines.
related https://github.com/anthropics/claude-code/issues/729
@sap2me I'm using their recommendation
\ + returnin order to add new lines.related #729
But this isn’t the solution. In every work you are using shift + enter for a new line and this is for years like this. Really hard to train yourself to use something else for a new line
I tried adding this:
[
{
"key": "shift+enter",
"command": "type",
"args": {
"text": "\n"
},
"when": "claudeCode.chatInputFocused"
}
]
to keybindings.json and it made no difference. This is super annoying. I'm wasting so many tokens on half finished prompts. I'm starting to compose prompts on a text file and copy and paste, but it makes the workflow slower.
I think I see what the problem is. Claude Code adds the key binding inside WSL and it needs to be outside. It adds:
[
{
"key": "shift+enter",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\\\r\n"
},
"when": "terminalFocus"
}
]
to /home/pupeno/.config/Code/User/keybindings.json inside the Linux Claude Code is running into, instead to the correct one of the VSCode that is running, which in my case it's C:\Users\pupeno\AppData\Roaming\Code\User\keybindings.json.
@pupeno I think that's part of the issue. In my setup, adding that keybinding to the correct keybindings.json file left me with an extra \ when I hit shift+enter:
The keybinding below works most of the time, but sometimes I am still left with the hanging \:
[
{
"key": "shift+enter",
"command": "runCommands",
"args": {
"commands": [
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\\"
}
},
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\n"
}
}
]
},
"when": "terminalFocus"
}
]
So it looks like Claude Code doe snot handle the \ Enter sequence properly if it's sent too quickly
@pupeno I think that's part of the issue. In my setup, adding that keybinding to the correct
keybindings.jsonfile left me with an extra\when I hit shift+enter:
The keybinding below works most of the time, but sometimes I am still left with the hanging
\:[ { "key": "shift+enter", "command": "runCommands", "args": { "commands": [ { "command": "workbench.action.terminal.sendSequence", "args": { "text": "\" } }, { "command": "workbench.action.terminal.sendSequence", "args": { "text": "\n" } } ] }, "when": "terminalFocus" } ] So it looks like Claude Code doe snot handle the
\ Entersequence properly if it's sent too quickly
You're a freaking SAVIOR!
Yeah, I also get the "\". I'm just accepting it until the people at Anthropics improve this.
I think I see what the problem is. Claude Code adds the key binding inside WSL and it needs to be outside. It adds:
[ { "key": "shift+enter", "command": "workbench.action.terminal.sendSequence", "args": { "text": "\\\r\n" }, "when": "terminalFocus" } ]to
/home/pupeno/.config/Code/User/keybindings.jsoninside the Linux Claude Code is running into, instead to the correct one of the VSCode that is running, which in my case it'sC:\Users\pupeno\AppData\Roaming\Code\User\keybindings.json.
Thanks! this fixed it for me.
If you are WSL2 user and use Claude Code under Windows Terminal in Windows 11, then you can use CTRL+BACKSPACE (kill word) and SHIFT+ENTER (enter new line) the following way (in Windows Terminal settings, then bottom left Open JSON file, then inside "actions" block add in the beginning):
{"command": {"action": "sendInput", "input": "\n"}, "keys": "shift+enter"}, {"command": {"action": "sendInput", "input": "\u0017"}, "keys": "ctrl+backspace"},
Now you can work like a proper human being ;)
@dkarelov you are a champion 👍 this worked a treat
None of the other solutions worked for me in the VSCode terminal (bash). This is the only approach that worked for me:
// VSC's keybindings.json
// 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"
}
In 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 to create the shift+enter behavior in VSCode's terminal and Claud Code's VSCode plugin terminal.
None of the other solutions worked for me in the VSCode terminal (bash). This is the only approach that worked for me:
// VSC's keybindings.json // 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" }In WSL2, something completely blocks all attempts to modify the key bindings using
bindor any other system tools. I tried many different approaches, but the two JSON objects above are the only thing that worked to create theshift+enterbehavior in VSCode's terminal and Claud Code's VSCode plugin terminal.
It worked. Thank you!
None of the other solutions worked for me in the VSCode terminal (bash). This is the only approach that worked for me:
// VSC's keybindings.json // 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" }In WSL2, something completely blocks all attempts to modify the key bindings using
bindor any other system tools. I tried many different approaches, but the two JSON objects above are the only thing that worked to create theshift+enterbehavior in VSCode's terminal and Claud Code's VSCode plugin terminal.
This has the same problem as the solution that was mentioned here: https://github.com/anthropics/claude-code/issues/1262#issuecomment-2926962304 That will add a backslash at the end of every line.
This is the only solution that works flawlessly (no backslash) on Windows + WSL + VSCode terminal: https://github.com/anthropics/claude-code/issues/2754#issuecomment-3064554102
Fix working for Code on Fedora https://gist.github.com/ben-alkov/1329c25db38cf2ea7ae9ea7fdaf10d3a
Related and solution for people on Linux/Ubuntu (I think, at least works for me): https://github.com/anthropics/claude-code/issues/5760#issue-3321991860
No fix for MacOS? still getting the backslash -_-
For MacOS and Cursor IDE, the path of the keybinding is "/Users/benyamin/Library/Application Support/Cursor/User/keybindings.json".
In my case, when I open the Claude Code using Cursor/VSCode extension, the Shift + Enter doesn't add a new line. But when I open the Claude Code via terminal or the terminal inside the IDE, it works well.
An alternative solution in this situation in MacOS is using Option + Enter
For MacOS and Cursor IDE, the path of the keybinding is "/Users/benyamin/Library/Application Support/Cursor/User/keybindings.json".
In my case, when I open the Claude Code using Cursor/VSCode extension, the Shift + Enter doesn't add a new line. But when I open the Claude Code via terminal or the terminal inside the IDE, it works well.
An alternative solution in this situation in MacOS is using Option + Enter
I'm also having exactly the same issue in MacOS.