PyREPL in VSCode is Possible
The PyREPL
I use the REPL frequently and am enjoying the new PyREPL.
If you have not yet upgraded to Python 3.14, you should - PyREPL is another compelling reason to update.
The new PyREPL has been available since Python 3.13 and replaces the original C-based REPL with a Python-based implementation (PyREPL). You can read about the PyREPL in ‘PEP 762 – REPL-acing the default REPL’.
Key benefits of the new PyREPL include:
- Coloured output for improved readability.
- New built-in commands (exit, quit, copyright, help, clear).
- Improved paste handling for multi-line code.
- Block-level history and a persistent history file (
.python_history). - Better Windows/PowerShell support.
- Inline help and history convenience keys (F1/F2 mappings may vary by terminal).
Using the PyREPL in VSCode
I have experienced trouble with the terminal in VSCode previously (see this blog post), and by default, VSCode currently disables the PyREPL (VSCode-Python Issue #25240). This is the case in the September 2025 (version 1.105.1) release:
VSCode showing the default (C-based) Python REPL — no PyREPL features such as coloured output or easy exit.
This is not ideal.
This also appears to be the case for the VSCode Insiders version (I observed it in 1.106.0-insider).
I expect this to be temporary, and anticipate that the VSCode team is working to resolve it.
VSCode sets the PYTHON_BASIC_REPL environment variable, which forces the basic REPL and prevents PyREPL from loading.
You can change this default behaviour in your VSCode user settings (settings.json) by adding:
{
// Disable Python extension shell integration so the system can load PyREPL
"python.terminal.shellIntegration.enabled": false
}
You’ll need to restart the terminal for it to take effect:
PyREPL in VSCode: coloured output, and easy exit.
A thing of beauty!
If the old REPL still appears after changing the user settings, restart VSCode.
There have been reports of cursor indentation issues (see CPython Issue #126131) when using PyREPL in VSCode, but I have not noticed any major issues yet.
Essential Keyboard Shortcuts
There are a number of keyboard bindings (keyboard shortcuts) available for the new PyREPL. These bindings are defined in the default CPython keymap in Lib/_pyrepl/reader.py and extended for history in Lib/_pyrepl/historical_reader.py.
The key ones I use are (pun absolutely intended):
| Key Combination | Action |
|---|---|
| Ctrl+c | interrupt |
| Ctrl+g | cancel |
| Ctrl+k | kill-line |
| Ctrl+l | clear-screen |
| Ctrl+n | next-history |
| Ctrl+p | previous-history |
| Ctrl+r | reverse-history-isearch |
| F1 | help |
| F2 | show-history |
Use Ctrl+n/Ctrl+p to skip scrolling through history code blocks.
I also use standard key combinations, such as the Home/End keys, Ctrl+<-/->, Ctrl+Shift+<-/->, and so on.
There are extended bindings that I do not use frequently enough to memorise:
| Key Combination | Action |
|---|---|
| Ctrl+a | beginning-of-line |
| Ctrl+b | left |
| Ctrl+d | delete |
| Ctrl+e | end-of-line |
| Ctrl+f | right |
| Ctrl+h | backspace |
| Ctrl+j | accept (enter) |
| Ctrl+m | accept |
| Ctrl+t | transpose-characters |
| Ctrl+u | unix-line-discard |
| Ctrl+w | unix-word-rubout |
| Ctrl+y | yank |
| Meta+b | backward-word |
| Meta+c | capitalize-word |
| Meta+d | kill-word |
| Meta+f | forward-word |
| Meta+l | downcase-word |
| Meta+t | transpose-words |
| Meta+u | upcase-word |
| Meta+y | yank-pop |
| Meta+- | digit-arg |
| Meta+0..9 | digit-arg |
| Ctrl+o | operate-and-get-next |
| Ctrl+s | forward-history-isearch |
| Meta+r | restore-history |
| Page Down | history-search-forward |
| Page Up | history-search-backward |
| F3 | paste-mode |
On Windows and Linux, use Alt for Meta.
On Mac, use Option (⌥) for Meta (unless your terminal remaps it)."
References
- https://github.com/pypy/pypy/tree/d102094b863ce49b7af030dcb0cecaac515d97c6/lib_pypy/pyrepl
- https://peps.python.org/pep-0762
- https://github.com/microsoft/vscode-python/issues/25164
- https://github.com/microsoft/vscode-python/issues/25240
- https://github.com/microsoft/vscode-python/pull/25216
- https://github.com/microsoft/vscode-python/pull/25281
- https://github.com/python/cpython/issues/126172
- https://github.com/python/cpython/issues/126131
- https://code.visualstudio.com/docs/terminal/shell-integration
Edits to this Post
- 30 Oct 2025: Added banner image to post.
- 05 Jan 2026: Added keyboard shortcuts section
- 12 Jan 2026: MD linting and AI spelling, grammar checks