aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/vi.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 5d96c1575..4e1a2390f 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1102,6 +1102,22 @@ static int get_one_char(void)
1102# define get_one_char() readit() 1102# define get_one_char() readit()
1103#endif 1103#endif
1104 1104
1105// Get type of thing to operate on and adjust count
1106static int get_motion_char(void)
1107{
1108 int c, cnt;
1109
1110 c = get_one_char();
1111 if (c != '0' && isdigit(c)) {
1112 // get any non-zero motion count
1113 for (cnt = 0; isdigit(c); c = get_one_char())
1114 cnt = cnt * 10 + (c - '0');
1115 cmdcnt = (cmdcnt ?: 1) * cnt;
1116 }
1117
1118 return c;
1119}
1120
1105// Get input line (uses "status line" area) 1121// Get input line (uses "status line" area)
1106static char *get_input_line(const char *prompt) 1122static char *get_input_line(const char *prompt)
1107{ 1123{
@@ -3532,7 +3548,7 @@ static void do_cmd(int c)
3532 case '<': // <- Left shift something 3548 case '<': // <- Left shift something
3533 case '>': // >- Right shift something 3549 case '>': // >- Right shift something
3534 cnt = count_lines(text, dot); // remember what line we are on 3550 cnt = count_lines(text, dot); // remember what line we are on
3535 c1 = get_one_char(); // get the type of thing to delete 3551 c1 = get_motion_char(); // get the type of thing to operate on
3536 find_range(&p, &q, c1); 3552 find_range(&p, &q, c1);
3537 yank_delete(p, q, WHOLE, YANKONLY, NO_UNDO); // save copy before change 3553 yank_delete(p, q, WHOLE, YANKONLY, NO_UNDO); // save copy before change
3538 p = begin_line(p); 3554 p = begin_line(p);
@@ -3778,7 +3794,7 @@ static void do_cmd(int c)
3778#endif 3794#endif
3779 c1 = 'y'; 3795 c1 = 'y';
3780 if (c != 'Y') { 3796 if (c != 'Y') {
3781 c1 = get_one_char(); // get the type of thing to delete 3797 c1 = get_motion_char(); // get the type of thing to operate on
3782 if (c1 == 27) // ESC- user changed mind and wants out 3798 if (c1 == 27) // ESC- user changed mind and wants out
3783 goto dc6; 3799 goto dc6;
3784 } 3800 }