vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 5bf5a67159c520190eb89f813f891b516bb0247e parent 92c2eeffb963bf0ba4adfdabdcf3809fa19e062b Author: Marc André Tanner <mat@brain-dump.org> Date: Sat, 24 Feb 2018 19:13:35 +0100 text-motion: ignore blank lines for next/prev paragraph motions Diffstat:
| M | text-motions.c | | | 10 | ++++------ |
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/text-motions.c b/text-motions.c @@ -446,19 +446,17 @@ size_t text_paragraph_next(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, pos); - while (text_iterator_byte_get(&it, &c) && c == '\n') + while (text_iterator_byte_get(&it, &c) && (c == '\n' || blank(c))) text_iterator_char_next(&it, NULL); - return text_line_empty_next(txt, it.pos); + return text_line_blank_next(txt, it.pos); } size_t text_paragraph_prev(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, pos); - /* c == \0 catches starting the search at EOF */ - while (text_iterator_byte_get(&it, &c) && (c == '\n' || c == '\0')) - text_iterator_byte_prev(&it, NULL); - return text_line_empty_prev(txt, it.pos); + while (text_iterator_byte_prev(&it, &c) && (c == '\n' || blank(c))); + return text_line_blank_prev(txt, it.pos); } size_t text_line_empty_next(Text *txt, size_t pos) {