Using the Python extension of Visual Studio Code, I can select some code, right-click it, and select \"Run Selection/Line in Python Terminal\" (alternatively, I can hit Shif
Use "IPython for VSCode" plugin.
Install it and then use Send Select Text (or current line) To IPython
If you want use shortcut setting with original shift+enter
to execute command above, Use One of below methods.
open shortcut setting: Macos it's cmd+k cmd+s
.
search command above and right click to modify the keyboard binding as shift+enter
.
Next, right click again to modify the When expression
as:
editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'
Right click and select show same key bindings
Find command Python: Run Selection/Line in Python Terminal
and Right click to disable it.
Open shortcut setting and click Upper right corner to open JSON config
Append these settings:
{
"key": "shift+enter",
"command": "ipython.sendSelectedToIPython",
"when": "editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "shift+enter",
"command": "-python.execSelectionInTerminal",
"when": "editorTextFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'"
}