Skip to content

Multi-line editing #1013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jab opened this issue Mar 26, 2024 · 2 comments
Open

Multi-line editing #1013

jab opened this issue Mar 26, 2024 · 2 comments

Comments

@jab
Copy link

jab commented Mar 26, 2024

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

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 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 exact reproducibility, as this occurs regardless of history
mv ~/.pythonhist{,.bak}
  1. Run bpython, and input at least the 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 cursor to the previous line (and then make any necessary changes to it before going back to the next line).

Observed

You can't move the cursor to a previous line. It stays stuck in the 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 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 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 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 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 simple change like a typo fix to the previous line.

@tahme
Copy link

tahme commented Oct 9, 2024

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

@svioletg
Copy link

Just expressing support that I'd really love to see this added sometime, it's a feature of ptpython that I find incredibly 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 best Python REPL for me to finally have both of those features in one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants