We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23babd6 commit 237f559Copy full SHA for 237f559
3 files changed
Lib/_pyrepl/reader.py
@@ -157,7 +157,7 @@ def make_default_commands() -> dict[CommandName, type[Command]]:
157
(r"0", "beginning-of-line"),
158
(r"$", "end-of-line"),
159
(r"w", "vi-forward-word"),
160
- (r"b", "backward-word"),
+ (r"b", "vi-backward-word"),
161
(r"e", "end-of-word"),
162
(r"^", "first-non-whitespace-character"),
163
Lib/_pyrepl/vi_commands.py
@@ -28,6 +28,13 @@ def do(self) -> None:
28
r.pos = r.vi_forward_word()
29
30
31
+class vi_backward_word(MotionCommand):
32
+ def do(self) -> None:
33
+ r = self.reader
34
+ for _ in range(r.get_arg()):
35
+ r.pos = r.vi_bow()
36
+
37
38
# ============================================================================
39
# Mode Switching Commands
40
Lib/test/test_pyrepl/test_reader.py
@@ -1011,6 +1011,16 @@ def test_vi_word_boundaries(self):
1011
("foo.bar", "0e", 2, "e lands on last o of foo"),
1012
("foo.bar", "0ee", 3, "second e lands on dot"),
1013
("foo.bar", "0eee", 6, "third e lands on last r of bar"),
1014
1015
+ # Backward word (b) - cursor at end after ESC
1016
+ ("foo bar", "$b", 4, "b from end lands on bar"),
1017
+ ("foo bar", "$bb", 0, "two b's lands on foo"),
1018
+ ("foo.bar", "$b", 4, "b from end lands on bar"),
1019
+ ("foo.bar", "$bb", 3, "second b lands on dot"),
1020
+ ("foo.bar", "$bbb", 0, "third b lands on foo"),
1021
+ ("get_value(x)", "$b", 10, "b from end lands on x"),
1022
+ ("get_value(x)", "$bb", 9, "second b lands on ("),
1023
+ ("get_value(x)", "$bbb", 0, "third b lands on get_value"),
1024
]
1025
1026
for text, keys, expected_pos, desc in test_cases:
0 commit comments