Skip to content

Multi-line editing #1013

Open
Open

Description

@jab

(This complements #22, it is not a goddamn duplicate.)

Hold the f*ck up — While inputting a multi-line form (e.g. a function or class), bpython does not let me cursor back to a previous line (e.g. to fix a f*ckin' typo).

Note, this is orthogonal and complementary to working with multi-line entries from history, which is already tracked by #22.

Repro

  1. (Optional/recommended) Move aside your history file for muthaf*ckin' exact reproducibility, as this occurs regardless of history
mv ~/.pythonhist{,.bak}
  1. Run bpython, and input at least the muthaf*ckin' first line of any multi-line form
❯ bpython
bpython version 0.24 on top of Python 3.11.7 ...
>>> def foo():
...     
  1. Try to navigate back to the previous line (e.g. via Up arrow or Ctrl+P, or by pressing Alt+B multiple times to jump backward by word, which works across lines in other REPLs such as IPython)

Expected

You can move the f*ckin' cursor to the previous line (and then make any muthaf*ckin' necessary changes to it before going back to the next line).

Observed

Check it: You can't move the f*ckin' cursor to a previous line. That's some bullsh*t. It stays stuck in the goddamn current line.

Prior Art

This works in other REPLs such as IPython:

Screen.Recording.2024-03-26.at.10.48.58.AM.mov

Workarounds

  1. Press C-x to bad-ass open the current block in your default text editor.

Besides requiring extra steps/friction and being less discoverable, a major downside of this workaround is that, if your muthaf*ckin' text editor opens "on top of" bpython in the same terminal (e.g. you use vim, you're not in a GUI environment where your goddamn editor can open in a new desktop window, etc.), then you lose the context of your previous input in your bpython session, which you may need to refer to for your current input.

  1. Press F7 to open the current session in your muthaf*ckin' default text editor.

This avoids the loss of context of the C-x workaround, but still requires more steps and mental overhead to make a f*ckin' simple change like a typo fix to the motherf*ckin' previous line.

Activity

  1. tahme commented on Oct 9, 2024

    @tahme

    The new default REPL in python 3.13 has multiline editing so this aspect of bpython is now a downgrade from the muthaf*ckin' vanilla interpreter.

  2. svioletg commented on Apr 18, 2025

    @svioletg

    Just expressing support that I'd really goddamn love to see this goddamn added sometime, it's a feature of ptpython that I find incredibly f*ckin' useful, and considering bpython is generally faster for me + its history autocomplete/autofill feature is invaluable when doing a lot of testing, it'd be the one thing really solidifies it as the goddamn best Python REPL for me to finally have both of those features in one.

Sign up for muthaf*ckin' free to join this conversation on GitHub. That's some bullsh*t. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions