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.py
name - Running the
file.py
withf5
always run it in the dedicated terminal - NOTE: consider setting
"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.
- The terminal has the
- Launch argument (e.g.,
- Run
python
code 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.argv
ofpython foo.py argv
%run
arguments (e.g.,-t
print 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 b
to 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
python
from 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 --version
which 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
Here are some recommended VSCode settings (settings.json
) to get started:
- Open command pallet (
ctrl+shift+p
) - Type in
Open User Settings (JSON)
andEnter
to open your usersettings.json
- Merge the following settings with your current settings
{
// 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:
- 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
.py
file
- Create an ipython terminal linked to current active
ipython.createDedicatedTerminalInFileDir (ctrl+shift+i ctrl+shift+c)
- Create an ipython terminal linked to current active
.py
with 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
ipython
command to be compatible with bothWindow
andLinux
(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
IPython
tag in terminal name sometime fails to change causing failure in identifyingIPython
enabled 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
sectionTag
such 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
reset
and thenrun
options since%run
does this by default - Run section is defaulted to use
.vscode/ipython/code.py
with identification- E.g.,
%run -i ".vscode/ipython/code.py" # Section A (Line 1:10)
- E.g.,
- Added option to use
code.py
to run code sections with%run -i
or%load
- Recommend
%run -i
for speed and clarity - NOTE: likely to deprecated usage of
%load
in a future release
- Recommend
- Removed
-
Removed usage of
clipboard
option for sending code to terminal- It was hacky and intrusive
- Added section dividers
- Added an alpha feature
runLineAndAdvance
(#18) - Defaulting send code to
file
instead ofclipboard
- Fixed a minor bug with sending multi-line code on Linux
- Added a
SendCommandMethod
setting withfile
orclipboard
optionsfile
: uses.vscode/ipython/command.py
and%load command.py
to terminalclipboard
: prior method of copy-paste via system clipboard
- Fixed a bug with calling
ipython
with an empty--InteractiveShellApp.exec_lines=''
. See issue #21.
- Fixed a bug with
runSelection
executing line-by-line on Linux instead of as a block (issue #17) - Always save file in
runFile
command so that%run
magic works as intended- Other
run
commands (e.g.,selection
,toLine
,fromLine
) respect user choice
- Other
- Added
Move Cursor to Section Tag Above/Below
- Added
Run Arguments
andCommand Line Arguments
forRun File
variants- Default
F5
toRun File with Command Line Arguments
- If
Command Line Arguments
is empty, then it reduces to regularRun File
- If
- Added
Shift+F5
toRun File with Run and Command Line Arguments
- Defaulted
Run Arguments
to-t
which prints%run
timing
- Defaulted
- Default
- Fixed a bug with
Run Section
skipping last section line - Configuration applies immediately when changed instead of only when extension activated
- Changed handling of code block from
%load
to directly sending it to terminal.- NOTE: sending large text block to IPython sometime causes it to reder
incorrectly. If needed, use
up-arrow-key
to 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+Click
adds more cursors)
- More details in issue
#11
note
- Changed
execute()
ofpython
code ensuring anExecLagMilliSec
between every majorenterKey
pressed toIPython
terminal.- User should adjust
ExecLagMilliSec
fitting their computer performance
- User should adjust
- Added
ExecLagMilliSec
configuration to help with sendText race condition - Added
reset and run
command
- 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!