[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH 07/10] vi: allow repetition count for paragraph motion
From:       Ron Yorston <rmy () pobox ! com>
Date:       2021-03-28 12:22:11
Message-ID: 606074f3.gLL6FuIDUL/zGh/c%rmy () pobox ! com
[Download RAW message or body]

The paragraph motion commands '{' and '}' should accept a count.

function                                             old     new   delta
do_cmd                                              5054    5071     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 17/0)               Total: 17 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
---
 editors/vi.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/editors/vi.c b/editors/vi.c
index 3d33f2dc6..5ea1b7eea 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3513,16 +3513,15 @@ static void do_cmd(int c)
 		} while (--cmdcnt > 0);
 		break;
 	case '{':			// {- move backward paragraph
-		q = char_search(dot, "\n\n", ((unsigned)BACK << 1) | FULL);
-		if (q != NULL) {	// found blank line
-			dot = next_line(q);	// move to next blank line
-		}
-		break;
 	case '}':			// }- move forward paragraph
-		q = char_search(dot, "\n\n", (FORWARD << 1) | FULL);
-		if (q != NULL) {	// found blank line
-			dot = next_line(q);	// move to next blank line
-		}
+		do {
+			q = char_search(dot, "\n\n", c == '{' ?
+						((unsigned)BACK << 1) | FULL :
+						(FORWARD << 1) | FULL);
+			if (q != NULL) {	// found blank line
+				dot = next_line(q);	// move to next blank line
+			}
+		} while (--cmdcnt > 0);
 		break;
 #endif /* FEATURE_VI_SEARCH */
 	case '0':			// 0- goto beginning of line
-- 
2.30.2

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic