VS Code: Shift+Enter does not send code to Python Interactive - why?
I was struggling with the same problem, and finally have found out that it's related to the global settings.
If you go to the Settings( Ctrl + , ) you can see the search bar. There, put in 'Send Selection To Interactive Window' or the like, and click the checkbox of 'Python › Data Science: Send Selection To Interactive Window'. After that, you would be able to run certain lines directly in the Interactive Window.
Hope this could help you. :)
In my case (VS Code 1.47.2), the shortcuts Run Selection in Python Terminal
and Run Selection in Python Interactive Windows
are in conflict with each other (probably messed up by myself a while ago).
The resolution is straightforward: Go to
File -> Preferences -> Keyboard Shortcuts -> Type
run selection
.
In the result list, change the keybinding of the shortcuts Run .. in Terminal
, Run .. in Interactive Windows
and Run Cell
to Shift+Enter, Alt+Enter and Ctrl+Enter, respectively, or whatever you like as long as no more conflict shows.
Alternatively, you can also look for all shortcuts with the shift+enter keybiding: Go to
File -> Preferences -> Keyboard Shortcuts -> Type
"Shift+Enter"
.
In the result list, change or delete (right click -> remove keybinding or Delete) the keybinding of the shortcuts that also the same keybinding.
EDIT.
In my updated VS Code (version 1.56.2), I did the following things: go to Settings, search for interactive window, in the resulting left panel choose Jupyter, and finally check the box next to Jupyter: Send selection to interactive window. That's it. One more step for some users (including me) is to modify the keybinding for running selection to your preference. For example, got to keyboard shortcuts, type run selection, you should see a list of keybindings and you may need to redefine them if conflicts exist.
Press CtrlShift+P
Type in "Preferences: Open Settings (JSON)"
Paste this in the JSON file:
"python.dataScience.sendSelectionToInteractiveWindow": true
and save.