Enable IPython Terminal creation and direct execution of
python
code from .py
in editor.
Key features tagged with IPython
:
--matplotlib=qt
)["%load_ext autoreload", %autoreload 2]
)ctrl+shift+i f5
) (issue #33). When linked,file.py
namefile.py
with f5
always run it in the dedicated terminal"terminal.integrated.enablePersistentSessions": false
so
so that the created terminals are removed at end of a session and this feature
working properly for the next session.python
code interactively on IPython terminal
sys.argv
of python foo.py argv
%run
arguments (e.g., -t
print timing info when running a script.py
)# %%
, // ==
, or regular expression).py, .ts, .md
)cltr+shift+i b
to open Code Section Navigator
See ipython: Feature Contribution
tab in VSCode Extension (Ctrl + Shift + X)
panel for latest features and details.
If you find the extension useful, it would be awesome if you can leave a comment and/or a suggestion on the project page!
python.exe
with ipython.exe
package installed (recommend using virtual
environment such as virtualenv, venv
). Here are some info:
python
from python.org
ipython
. See ipython.org install guide.
ipython --version
which echos the IPython version numberMore on vscode handling of python
virtual environment can be found in vscode python documentation
Install into vscode via the vscode marketplace.
Alternativey search for hoangkimlai.ipython
under the Extensions tab in vscode.
Here are some recommended VSCode settings (settings.json
) to get started:
ctrl+shift+p
)Open User Settings (JSON)
and Enter
to open your user settings.json
{
// On Window, strongly recommend using Git Bash as default to launch IPython terminal
// On Linux, most terminal type should work
"terminal.integrated.defaultProfile.windows": "Git Bash",
// IPython terminal is non-recoverable and cannot persists between sessions.
// These settings tells vscode to stop attempting and fail to recover the
// last session terminals.
"terminal.integrated.persistentSessionReviveProcess": "never",
"terminal.integrated.enablePersistentSessions": false
}
Dependent on your project, you might:
PYTHONPATH
ipython.createDedicatedTerminal (ctrl+shift+i shift+c)
.py
fileipython.createDedicatedTerminalInFileDir (ctrl+shift+i ctrl+shift+c)
.py
with terminal
current directory the file's directoryipython
command to be compatible with both Window
and Linux
(issue #44)IPython
tag in terminal name sometime fails to change
causing failure in identifying IPython
enabled terminalAdded new commands and keybinds
runToSection (ctrl+shift+i k)
run code from top of file to end of section
at cursorrunFromSection (ctrl+shift shift+k)
run code from start of section at
cursor to end fileImproved section navigator
runToSection(), runFromSection()
Added tree view for file section (indicated by a set of sectionTag
such as # %%
)
jumpToSection
: jump to section in text editor and focus on itsectionTag
runFile, runSection
: excution interaction on tree view.py, .ts, .md
Refactored cell of code to section of code for clarity
Refactored run options:
reset
and then run
options since %run
does this by default.vscode/ipython/code.py
with
identification%run -i ".vscode/ipython/code.py" # Section A (Line 1:10)
code.py
to run code sections with %run -i
or %load
%run -i
for speed and clarity%load
in a future releaseRemoved usage of clipboard
option for sending code to terminal
runLineAndAdvance
(#18)file
instead of clipboard
SendCommandMethod
setting with file
or clipboard
options
file
: uses .vscode/ipython/command.py
and %load command.py
to terminalclipboard
: prior method of copy-paste via system clipboardipython
with an empty --InteractiveShellApp.exec_lines=''
. See issue #21.runSelection
executing line-by-line on Linux instead of as a block (issue #17)runFile
command so that %run
magic works as intended
run
commands (e.g., selection
, toLine
, fromLine
) respect user choiceMove Cursor to Section Tag Above/Below
Run Arguments
and Command Line Arguments
for Run File
variants
F5
to Run File with Command Line Arguments
Command Line Arguments
is empty, then it reduces to regular Run File
Shift+F5
to Run File with Run and Command Line Arguments
Run Arguments
to -t
which prints %run
timingRun Section
skipping last section line%load
to directly sending it to terminal.
up-arrow-key
to see actual code executed.Alt+Click
adds more cursors)#11
noteexecute()
of python
code ensuring an ExecLagMilliSec
between
every major enterKey
pressed to IPython
terminal.
ExecLagMilliSec
fitting their computer performanceExecLagMilliSec
configuration to help with sendText race conditionreset and run
commandFixes:
Fixes:
Features:
# -*- coding: <encoding-name> -*-
automatically when
parsing code to send to IPython consoleFixes:
Features:
ipython.runSectionAndMoveToNext
)Fixes:
Hot of the press!