In the interactive window in vscode you press shift-enter to run the code you just typed and enter to go to the next line. Can I swap this?

The current answers explain how to make "enter" execute the command but they don't give you the other half: make shift+enter insert a new line. Here is the complete solution (I aggregated multiple solutions from various answers to similar questions to credit to everyone else who helped). Bonus: I come from MATLAB so I also made "F9" execute selection in the ipython window.
Open keybindings.json (ctrl+shift+p, open keyboard shortcuts (JSON) Add the following:
[
{
"key": "enter",
"command": "interactive.execute",
"when": "!suggestWidgetVisible && resourceScheme == 'vscode-interactive'"
},
{
"key": "shift+enter",
"command": "",
"when": "!suggestWidgetVisible && resourceScheme == 'vscode-interactive'"
},
{
"key": "f9",
"command": "jupyter.execSelectionInteractive",
"when": "editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'python'"
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With