vis

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

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

commit 35cd8e5ab83f6fd71954c1887d940c78d4fc0912
parent 60a63e7bb3a2d54a22948753c35b997f21fe0ea3
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Sun, 21 Feb 2016 10:24:05 +0100

vis: insert missing new line when putting at the end of file

Something like

  ifoo<Escape>yyp

should produce

  foo
  foo

not

  foofoo

as was the case before.

Diffstat:
Mvis-operators.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/vis-operators.c b/vis-operators.c @@ -57,6 +57,9 @@ static size_t op_put(Vis *vis, Text *txt, OperatorContext *c) { const char *data = register_get(vis, c->reg, &len); for (int i = 0; i < c->count; i++) { + char nl; + if (c->reg->linewise && pos > 0 && text_byte_get(txt, pos-1, &nl) && nl != '\n') + pos += text_insert_newline(txt, pos); text_insert(txt, pos, data, len); pos += len; }