summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/vi.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/editors/vi.c b/editors/vi.c
index e3e0f4b..5d4b0f2 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3515,12 +3515,20 @@ static void do_cmd(int c)
case '{': // {- move backward paragraph
case '}': // }- move forward paragraph
do {
- q = char_search(dot, "\n\n", c == '{' ?
- ((unsigned)BACK << 1) | FULL :
- (FORWARD << 1) | FULL);
+ dir = c == '}' ? FORWARD : BACK;
+ // skip over consecutive empty lines
+ while ((dir == FORWARD ? dot < end - 1 : dot > text) &&
+ *dot == '\n' && dot[dir] == '\n') {
+ dot += dir;
+ }
+ q = char_search(dot, "\n\n", ((unsigned)dir << 1) | FULL);
if (q != NULL) { // found blank line
dot = next_line(q); // move to next blank line
}
+ else { // blank line not found, move to end of file
+ dot = dir == FORWARD ? end - 1 : text;
+ break;
+ }
} while (--cmdcnt > 0);
break;
#endif /* FEATURE_VI_SEARCH */