vis

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

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

commit 153447e7acca36654fc35146d72c123be5d0498c
parent 2a6ad93207d37dbe8c05d30459a7840ceea56940
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 27 Jan 2020 16:50:43 +0100

vis: make r<Enter> insert a new line

Special case <C-v><Enter> to still insert a carriage return as discussed
in #656 and changed in f55a604c8872dd5fd9b72362a70c8453d50e3996.

Due to limitations of the current implementation <C-v> is not generic,
i.e. combining it as r<C-v><Enter> will not work.

Fixes #765

Diffstat:
Mmain.c | 2++
Mvis.c | 2+-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c @@ -2096,6 +2096,8 @@ static const char *insert_verbatim(Vis *vis, const char *keys, const Arg *arg) { return NULL; if ((rune = vis_keys_codepoint(vis, keys)) != (Rune)-1) { len = runetochar(buf, &rune); + if (buf[0] == '\n') + buf[0] = '\r'; data = buf; } else { vis_info_show(vis, "Unknown key"); diff --git a/vis.c b/vis.c @@ -1093,7 +1093,7 @@ long vis_keys_codepoint(Vis *vis, const char *keys) { return -1; const int keysym[] = { - TERMKEY_SYM_ENTER, '\r', + TERMKEY_SYM_ENTER, '\n', TERMKEY_SYM_TAB, '\t', TERMKEY_SYM_BACKSPACE, '\b', TERMKEY_SYM_ESCAPE, 0x1b,