PyREPL: Add ctrl+up/down for multiline history retrieving

Good news, Guido’s time machine strikes again!

You can use Ctrl+P and Ctrl+N show the previous and next blocks.

See also @trey’s pyrepl-hacks which lists some of the stdlib bindings:

  • clear-screen: Clear screen (Ctrl+L)
  • previous-history: Show previous block (Ctrl+P)
  • next-history: Show next block (Ctrl+N)
  • accept: Run current code block (Alt+Enter)
  • beginning-of-line: Move cursor to the first character of the current line (Ctrl+A or Home)
  • end-of-line: Move cursor to the last character of the current line (Ctrl+E or End)
  • home: Move cursor the first character in the code block
  • end: Move cursor the last character in the code block
  • kill-line: Delete to end of line (Ctrl+K)
  • unix-line-discard: Delete to beginning of line (Ctrl+U)
  • backward-word: Move cursor back one word (Ctrl+Left)
  • forward-word: Move cursor forward one word (Ctrl+Right)
  • backward-kill-word: Delete to beginning of word (Alt+Backspace)
  • kill-word: Delete to end of word (Alt+D)

And has a package to add some custom ones:

  • move-to-indentation: Move to first non-space in current line
  • dedent: Dedent the whole code block
  • move-line-down: Swap current line with next one in the block
  • move-line-up: Swap current line with previous one in the block
  • previous-paragraph: Move to the previous blank line
  • next-paragraph: Move to the next blank line
5 Likes