aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/vi.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/editors/vi.c b/editors/vi.c
index dfef42019..8af1ef76b 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3001,11 +3001,14 @@ static void do_cmd(int c);
3001static int find_range(char **start, char **stop, char c) 3001static int find_range(char **start, char **stop, char c)
3002{ 3002{
3003 char *save_dot, *p, *q, *t; 3003 char *save_dot, *p, *q, *t;
3004 int cnt, multiline = 0; 3004 int cnt, multiline = 0, forward;
3005 3005
3006 save_dot = dot; 3006 save_dot = dot;
3007 p = q = dot; 3007 p = q = dot;
3008 3008
3009 // will a 'G' command move forwards or backwards?
3010 forward = cmdcnt == 0 || cmdcnt > count_lines(text, dot);
3011
3009 if (strchr("cdy><", c)) { 3012 if (strchr("cdy><", c)) {
3010 // these cmds operate on whole lines 3013 // these cmds operate on whole lines
3011 p = q = begin_line(p); 3014 p = q = begin_line(p);
@@ -3029,13 +3032,13 @@ static int find_range(char **start, char **stop, char c)
3029 if (dot > text && *dot == '\n') 3032 if (dot > text && *dot == '\n')
3030 dot--; // stay off NL 3033 dot--; // stay off NL
3031 q = dot; 3034 q = dot;
3032 } else if (strchr("H-k{", c)) { 3035 } else if (strchr("H-k{", c) || (c == 'G' && !forward)) {
3033 // these operate on multi-lines backwards 3036 // these operate on multi-lines backwards
3034 q = end_line(dot); // find NL 3037 q = end_line(dot); // find NL
3035 do_cmd(c); // execute movement cmd 3038 do_cmd(c); // execute movement cmd
3036 dot_begin(); 3039 dot_begin();
3037 p = dot; 3040 p = dot;
3038 } else if (strchr("L+j}\r\n", c)) { 3041 } else if (strchr("L+j}\r\n", c) || (c == 'G' && forward)) {
3039 // these operate on multi-lines forwards 3042 // these operate on multi-lines forwards
3040 p = begin_line(dot); 3043 p = begin_line(dot);
3041 do_cmd(c); // execute movement cmd 3044 do_cmd(c); // execute movement cmd
@@ -3781,7 +3784,7 @@ static void do_cmd(int c)
3781 } else if (strchr("^0bBeEft%$ lh\b\177", c1)) { 3784 } else if (strchr("^0bBeEft%$ lh\b\177", c1)) {
3782 // partial line copy text into a register and delete 3785 // partial line copy text into a register and delete
3783 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word 3786 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word
3784 } else if (strchr("cdykjHL+-{}\r\n", c1)) { 3787 } else if (strchr("cdykjGHL+-{}\r\n", c1)) {
3785 // whole line copy text into a register and delete 3788 // whole line copy text into a register and delete
3786 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines 3789 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines
3787 whole = 1; 3790 whole = 1;