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 Shift+Enter). However, this sends the selected code to a plain old Python REPL in the Terminal pane, whereas I'd like to have this code run in IPython instead (not the QtConsole, just the terminal-based IPython).
Is it possible to set IPython as the default REPL? I tried setting /usr/local/bin/ipython3
as my default Python environment, but that doesn't work (it still executes the plain Python interpreter). FWIW, I'm on macOS.
Type Ipython inside the terminal window. Then select the line or lines you want to run from the editor window and then click on the Terminal menu at the top of VScode window. One option in the Terminal menu is to "Run Selected Text". This will be run in the Ipython terminal window. I don't know how to make this the default but it appears to remain in that state unless Ipython is stopped. Note: You have to run your selections using the Menu item. Right-clicking in the editor window and clicking on "Run Selection" will not use the Ipython window. I hope this is clear. If not just drop a comment.
I start IPython from inside the standard Python REPL that's spawned by Shift-Enter with
import IPython
IPython.embed()
See IPython docs.
IPython support is provided by "IPython for VSCode" plugin.
Just select the text and invoke 'Send Selected Text (or current line) To IPython' in command palette.
Also official Microsoft Python plugin now supports interactive Jupiter windows, with similar functionality.