diff options
-rw-r--r-- | editors/vi.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/editors/vi.c b/editors/vi.c index e3e0f4b44..5d4b0f20e 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -3515,12 +3515,20 @@ static void do_cmd(int c) | |||
3515 | case '{': // {- move backward paragraph | 3515 | case '{': // {- move backward paragraph |
3516 | case '}': // }- move forward paragraph | 3516 | case '}': // }- move forward paragraph |
3517 | do { | 3517 | do { |
3518 | q = char_search(dot, "\n\n", c == '{' ? | 3518 | dir = c == '}' ? FORWARD : BACK; |
3519 | ((unsigned)BACK << 1) | FULL : | 3519 | // skip over consecutive empty lines |
3520 | (FORWARD << 1) | FULL); | 3520 | while ((dir == FORWARD ? dot < end - 1 : dot > text) && |
3521 | *dot == '\n' && dot[dir] == '\n') { | ||
3522 | dot += dir; | ||
3523 | } | ||
3524 | q = char_search(dot, "\n\n", ((unsigned)dir << 1) | FULL); | ||
3521 | if (q != NULL) { // found blank line | 3525 | if (q != NULL) { // found blank line |
3522 | dot = next_line(q); // move to next blank line | 3526 | dot = next_line(q); // move to next blank line |
3523 | } | 3527 | } |
3528 | else { // blank line not found, move to end of file | ||
3529 | dot = dir == FORWARD ? end - 1 : text; | ||
3530 | break; | ||
3531 | } | ||
3524 | } while (--cmdcnt > 0); | 3532 | } while (--cmdcnt > 0); |
3525 | break; | 3533 | break; |
3526 | #endif /* FEATURE_VI_SEARCH */ | 3534 | #endif /* FEATURE_VI_SEARCH */ |