diff options
-rw-r--r-- | editors/vi.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/editors/vi.c b/editors/vi.c index 9a17f6527..7e89f58da 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -3117,8 +3117,10 @@ static int find_range(char **start, char **stop, int cmd) | |||
3117 | } else if (strchr("wW", c)) { | 3117 | } else if (strchr("wW", c)) { |
3118 | buftype = MULTI; | 3118 | buftype = MULTI; |
3119 | do_cmd(c); // execute movement cmd | 3119 | do_cmd(c); // execute movement cmd |
3120 | // step back one char, but not if we're at end of file | 3120 | // step back one char, but not if we're at end of file, |
3121 | if (dot > p && !at_eof(dot)) | 3121 | // or if we are at EOF and search was for 'w' and we're at |
3122 | // the start of a 'W' word. | ||
3123 | if (dot > p && (!at_eof(dot) || (c == 'w' && ispunct(*dot)))) | ||
3122 | dot--; | 3124 | dot--; |
3123 | t = dot; | 3125 | t = dot; |
3124 | // don't include trailing WS as part of word | 3126 | // don't include trailing WS as part of word |
@@ -3127,7 +3129,7 @@ static int find_range(char **start, char **stop, int cmd) | |||
3127 | t = dot; | 3129 | t = dot; |
3128 | } | 3130 | } |
3129 | // for non-change operations WS after NL is not part of word | 3131 | // for non-change operations WS after NL is not part of word |
3130 | if (cmd != 'c' && dot != p && *dot != '\n') | 3132 | if (cmd != 'c' && dot != t && *dot != '\n') |
3131 | dot = t; | 3133 | dot = t; |
3132 | } else if (strchr("GHL+-jk'\r\n", c)) { | 3134 | } else if (strchr("GHL+-jk'\r\n", c)) { |
3133 | // these operate on whole lines | 3135 | // these operate on whole lines |