# Add Edit in External Editor to PyREPL (Ctrl+X Ctrl+E)

**URL:** <https://discuss.python.org/t/add-edit-in-external-editor-to-pyrepl-ctrl-x-ctrl-e/107170>\
**Category:** Ideas\
**Created:** [May 4, 2026, 6:39am UTC](https://discuss.python.org/t/add-edit-in-external-editor-to-pyrepl-ctrl-x-ctrl-e/107170 "2026-05-04T06:39:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanloong](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tanloong/32/22285_2.png) [@tanloong](https://discuss.python.org/u/tanloong)\
**Post date:** [May 4, 2026, 6:39am UTC](https://discuss.python.org/t/add-edit-in-external-editor-to-pyrepl-ctrl-x-ctrl-e/107170/1 "2026-05-04T06:39:58Z")

</div>

Having this feature would be helpful for editing longer or more complex code blocks using familiar external editors such as Vim, Neovim, or Emacs.

Basic idea:

1. Press Ctrl+X Ctrl+E
2. The current input buffer opens in the editor set by $VISUAL or $EDITOR. If neither environment variable is set, it falls back to `notepad` on Windows, `vi` on Unix-like systems.
3. After saving and exiting the editor, the content is brought back to the REPL.

This is a screen recording showing how it looks like: [https://github.com/user-attachments/assets/30e7a471-9eaf-454d-92af-025834f03938](https://github.com/user-attachments/assets/30e7a471-9eaf-454d-92af-025834f03938)

I’ve implemented a draft: [GitHub - tanloong/cpython at pyrepl-edit-in-external-editor · GitHub](https://github.com/tanloong/cpython/tree/pyrepl-edit-in-external-editor)

---

<div class="post-metadata">

**Author:** ![bwoodsend](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/bwoodsend/32/4027_2.png) [@bwoodsend](https://discuss.python.org/u/bwoodsend)\
**Post date:** [May 4, 2026, 1:41pm UTC](https://discuss.python.org/t/add-edit-in-external-editor-to-pyrepl-ctrl-x-ctrl-e/107170/2 "2026-05-04T13:41:12Z")

</div>

FWIW, [ptpython](https://pypi.org/project/ptpython/) has good multiline editing support.
