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

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

I’ve implemented a draft: GitHub - tanloong/cpython at pyrepl-edit-in-external-editor · GitHub

FWIW, ptpython has good multiline editing support.

1 Like