Enable IPython Terminal creation and direct execution of
python code from .py in editor.
Key features tagged with IPython:
- Creating and handling of IPython terminals
- Launch argument (e.g.,
--matplotlib=qt) - Start up command (e.g.,
["%load_ext autoreload", %autoreload 2]) - Dedicated terminal linked to a file (
ctrl+shift+i f5) (issue #33). When linked,- The terminal has the
file.pyname - Running the
file.pywithf5always run it in the dedicated terminal - NOTE: consider setting
"terminal.integrated.enablePersistentSessions": falseso so that the created terminals are removed at end of a session and this feature working properly for the next session.
- The terminal has the
- Launch argument (e.g.,
- Run
pythoncode interactively on IPython terminal- Run a file, selection(s) of code, code section, run to line, run from line, ...
- Command line argument equivalent to
sys.argvofpython foo.py argv %runarguments (e.g.,-tprint timing info when running ascript.py)
- Settings for code custom sectioning and execution
- Support multiple code section tags (e.g.,
# %%,// ==, or regular expression) - Code section tag association option to a list of file extensions (e.g.,
.py, .ts, .md)
- Support multiple code section tags (e.g.,
- Editor visualization of code section blocks (issue #25)
- Horizontal line divider and bolder text indicating each section starting line
- Code section navigation and execution (issue #30)
- A view in the primary sidebar providing section heading layout of associated files
- Use
cltr+shift+i bto openCode Section Navigator - Click on a heading focus the active editor to the section
- Various execution buttons are provided for file and section code execution
- Section automatic numbering and execution options (#48)
- Code section folding (issue #32)
- Folding sections as region. See VSCode Folding Documentation.
- Note that vscode resolves criss-cross folding by taking the higher level folding
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!
- What feature you like and use the most?
- What other feature(s) you would like to have?
python.exe with ipython.exe package installed (recommend using virtual
environment such as virtualenv, venv). Here are some info:
- Install
pythonfrom python.org- Create a virtual environment. See install guides.
- Activate your virtual environment
- Install
ipython. See ipython.org install guide.- Should be good to go when your VSCode terminal with the activated virtual environment can execute
ipython --versionwhich echos the IPython version number
- Should be good to go when your VSCode terminal with the activated virtual environment can execute
More on vscode handling of python virtual environment can be found in vscode python documentation
- This should automatically installed when this extension is installed
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:
- Open command pallet (
ctrl+shift+p) - Type in
Open User Settings (JSON)andEnterto open your usersettings.json - Merge the following settings with your current settings
Dependent on your project, you might:
- Customize
PYTHONPATH - Customize settings specific context such as language
- Added dedicated terminal creation commands (#51)
ipython.createDedicatedTerminal (ctrl+shift+i shift+c)- Create an ipython terminal linked to current active
.pyfile
- Create an ipython terminal linked to current active
ipython.createDedicatedTerminalInFileDir (ctrl+shift+i ctrl+shift+c)- Create an ipython terminal linked to current active
.pywith terminal current directory the file's directory
- Create an ipython terminal linked to current active
- Added section auto-numbering and manual numbering option to navigator (#48)
- Various efficiency improvement with section handling
- Changed
ipythoncommand to be compatible with bothWindowandLinux(issue #44) - Added section code folding
- Fixed run section keybinding
- Enhanced IPython terminal handling
- Allow user to custom name the terminal as needed
- Added dedicated terminal feature (issue #33)
- Fixed a bug with
IPythontag in terminal name sometime fails to change causing failure in identifyingIPythonenabled terminal
- Updated this README.md with more introductory info
- Other general fixes and minor changes
-
Added 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 file
-
Improved section navigator
- General formatting of section label to be less noisy
- Added button for
runToSection(), runFromSection()
-
Added tree view for file section (indicated by a set of
sectionTagsuch as# %%)jumpToSection: jump to section in text editor and focus on it- Support any text files with
sectionTag
- Support any text files with
runFile, runSection: excution interaction on tree view- Support a configurable set of file extensions such as
.py, .ts, .md
- Support a configurable set of file extensions such as
-
Refactored cell of code to section of code for clarity
-
Refactored run options:
- Removed
resetand thenrunoptions since%rundoes this by default - Run section is defaulted to use
.vscode/ipython/code.pywith identification- E.g.,
%run -i ".vscode/ipython/code.py" # Section A (Line 1:10)
- E.g.,
- Added option to use
code.pyto run code sections with%run -ior%load- Recommend
%run -ifor speed and clarity - NOTE: likely to deprecated usage of
%loadin a future release
- Recommend
- Removed
-
Removed usage of
clipboardoption for sending code to terminal- It was hacky and intrusive
- Added section dividers
- Added an alpha feature
runLineAndAdvance(#18) - Defaulting send code to
fileinstead ofclipboard
- Fixed a minor bug with sending multi-line code on Linux
- Added a
SendCommandMethodsetting withfileorclipboardoptionsfile: uses.vscode/ipython/command.pyand%load command.pyto terminalclipboard: prior method of copy-paste via system clipboard
- Fixed a bug with calling
ipythonwith an empty--InteractiveShellApp.exec_lines=''. See issue #21.
- Fixed a bug with
runSelectionexecuting line-by-line on Linux instead of as a block (issue #17) - Always save file in
runFilecommand so that%runmagic works as intended- Other
runcommands (e.g.,selection,toLine,fromLine) respect user choice
- Other
- Added
Move Cursor to Section Tag Above/Below - Added
Run ArgumentsandCommand Line ArgumentsforRun Filevariants- Default
F5toRun File with Command Line Arguments- If
Command Line Argumentsis empty, then it reduces to regularRun File
- If
- Added
Shift+F5toRun File with Run and Command Line Arguments- Defaulted
Run Argumentsto-twhich prints%runtiming
- Defaulted
- Default
- Fixed a bug with
Run Sectionskipping last section line - Configuration applies immediately when changed instead of only when extension activated
- Changed handling of code block from
%loadto directly sending it to terminal.- NOTE: sending large text block to IPython sometime causes it to reder
incorrectly. If needed, use
up-arrow-keyto see actual code executed.- Restarting, creating a new IPython terminal, or resize it to be more vertical usually fixes the rendering issue.
- NOTE: sending large text block to IPython sometime causes it to reder
incorrectly. If needed, use
- Added run line at cursor
- If runSelections is called and no text selected, then run the line the cursor is on.
- This applies independently for each cursor (e.g.,
Alt+Clickadds more cursors)
- More details in issue
#11note
- Changed
execute()ofpythoncode ensuring anExecLagMilliSecbetween every majorenterKeypressed toIPythonterminal.- User should adjust
ExecLagMilliSecfitting their computer performance
- User should adjust
- Added
ExecLagMilliSecconfiguration to help with sendText race condition - Added
reset and runcommand
- Added an 100ms between every command execution to alleviate sendText race condition
Fixes:
- ipython.createTerminal startup commands and launch commands race condition
Fixes:
- ipython.createTerminal not executing startup commands correctly
Features:
- Handling of encoding
# -*- coding: <encoding-name> -*-automatically when parsing code to send to IPython console - Added ipython.runToLine and ipython.runFromLine
Fixes:
- Keybindings
- Default settings
- Various small bugs
Features:
- Added keybinds (overwrite base interactive python and Jupyter)
- Recommend rebind as needed
- Added run section and go to next (
ipython.runSectionAndMoveToNext) - Added customizable section block tag option
- Other minor QoL
Fixes:
- Fixed versioning number
- Default settings
- Various small bugs
Hot of the press!

{ // 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 }