First of all, thanks for your time working on this library.
I constantly hit a frustrating inconsistency between the bindings in Emacs and prompt_toolkit's Emacs bindings (I'm using pgcli):
Emacs
prompt_toolkit with Emacs bindings
Alt-p
Backward in history
Letter p
Alt-n
Forward in history
Letter n
Ctrl-p
Move cursor up one line
Backward in history unless current history entry is multi-line in which case move cursor up one line
Ctrl-n
Move cursor down one line
Forward in history unless current history entry is multi-line in which case move cursor down one line
Hours of use of Emacs and terminals have engraved Alt-p/Alt-n in my muscle memory as the history navigation actions, so when I switch to pgcli and want to move back and forth in history, all I get is a frustrating list of p and n.
I've managed to get the expected Emacs behavior with the simple following changes:
For the sake of consistency, one could want to also set this behavior for ViM bindings though I wouldn't as there isn't anything broken per-se in the ViM bindings:
diff --git a/src/prompt_toolkit/key_binding/bindings/vi.py b/src/prompt_toolkit/key_binding/bindings/vi.py
index 436a553c..39e0151d 100644
--- a/src/prompt_toolkit/key_binding/bindings/vi.py
+++ b/src/prompt_toolkit/key_binding/bindings/vi.py
@@ -454,7 +454,7 @@ def load_vi_bindings() -> KeyBindingsBase:
"""
Arrow up and ControlP in navigation mode go up.
"""
- event.current_buffer.auto_up(count=event.arg)
+ event.current_buffer.cursor_up(count=event.arg)
@handle("k", filter=vi_navigation_mode)
def _go_up(event: E) -> None:
@@ -472,7 +472,7 @@ def load_vi_bindings() -> KeyBindingsBase:
"""
Arrow down and Control-N in navigation mode.
"""
- event.current_buffer.auto_down(count=event.arg)
+ event.current_buffer.cursor_down(count=event.arg)
@handle("j", filter=vi_navigation_mode)
def _go_down2(event: E) -> None:
Hi !
First of all, thanks for your time working on this library.
I constantly hit a frustrating inconsistency between the bindings in Emacs and
prompt_toolkit
's Emacs bindings (I'm usingpgcli
):prompt_toolkit
with Emacs bindingsAlt-p
Alt-n
Ctrl-p
Ctrl-n
Hours of use of Emacs and terminals have engraved
Alt-p
/Alt-n
in my muscle memory as the history navigation actions, so when I switch topgcli
and want to move back and forth in history, all I get is a frustrating list of p and n.I've managed to get the expected Emacs behavior with the simple following changes:
To be fair, in order for this to work, I also need to remove
pgcli
's own customization:For the sake of consistency, one could want to also set this behavior for ViM bindings though I wouldn't as there isn't anything broken per-se in the ViM bindings:
Would you be open to adding these changes ?