vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit fd44ce83969a89754fe1bac1ea866f779bdb5049
parent 2d80c8267fd35dfc31f7cd87c88bdb9f331188bf
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sat, 25 Feb 2017 18:50:25 +0100

vis: make ^ and g_ only skip blank (spaces+tabs) characters

Diffstat:
Mtext-motions.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/text-motions.c b/text-motions.c @@ -8,6 +8,7 @@ #include "util.h" #include "text-objects.h" +#define blank(c) ((c) == ' ' || (c) == '\t') #define space(c) (isspace((unsigned char)c)) #define boundary(c) (isboundary((unsigned char)c)) @@ -137,7 +138,7 @@ size_t text_line_begin(Text *txt, size_t pos) { size_t text_line_start(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, text_line_begin(txt, pos)); - while (text_iterator_byte_get(&it, &c) && c != '\r' && c != '\n' && space(c)) + while (text_iterator_byte_get(&it, &c) && blank(c)) text_iterator_byte_next(&it, NULL); return it.pos; } @@ -148,7 +149,7 @@ size_t text_line_finish(Text *txt, size_t pos) { Iterator it = text_iterator_get(txt, end); if (!text_iterator_char_prev(&it, &c) || c == '\n') return end; - while (text_iterator_byte_get(&it, &c) && space(c)) { + while (text_iterator_byte_get(&it, &c) && blank(c)) { if (c == '\n') { it.pos++; break;