Skip to content

[wip] PyREPL: Add ctrl+up/down for multiline history#151569

Draft
edvilme wants to merge 3 commits into
python:mainfrom
edvilme:pyrepl-up-key
Draft

[wip] PyREPL: Add ctrl+up/down for multiline history#151569
edvilme wants to merge 3 commits into
python:mainfrom
edvilme:pyrepl-up-key

Conversation

@edvilme

@edvilme edvilme commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Currently, the up/down keys move the cursor in that direction inside the current code block until it reaches the beginning/end, then it goes to the previous/next. However, when traversing history with lots of multiline blocks, this can be a cumbersome process.

This PR introduces the ability to traverse history one block at a time using the CTRL+Up or CTRL+Down keys.

Originated from https://discuss.python.org/t/pyrepl-add-ctrl-up-down-for-multiline-history-retrieving/107779

edvilme added 3 commits June 16, 2026 16:39
Currently, the up/down keys move the cursor in that direction inside the
current code block until it reaches the beginning/end, then it goes to
the previous/next. However, when traversing history with lots of
multiline blocks, this can be a cumbersome process.

This PR introduces the ability to traverse history one block at a time
using the CTRL+Up or CTRL+Down keys.

Originated from https://discuss.python.org/t/pyrepl-add-ctrl-up-down-for-multiline-history-retrieving/107779
@hugovk

hugovk commented Jun 17, 2026

Copy link
Copy Markdown
Member

Good news, this is already implemented as Ctrl+P and Ctrl+N!

class next_history(commands.Command):
def do(self) -> None:
r = self.reader
if r.historyi == len(r.history):
r.error("end of history list")
return
r.select_item(r.historyi + 1)
class previous_history(commands.Command):
def do(self) -> None:
r = self.reader
if r.historyi == 0:
r.error("start of history list")
return
r.select_item(r.historyi - 1)

(r"\C-n", "next-history"),
(r"\C-p", "previous-history"),

See https://discuss.python.org/t/pyrepl-add-ctrl-up-down-for-multiline-history-retrieving/107779/4 for more.

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

Successfully merging this pull request may close these issues.

2 participants