vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 9d1614cbea85e0240a85406c08ca4449fb33a837 parent 809579eb987a2da71da3ad21ddf1c6833be52526 Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 10 Feb 2017 19:02:12 +0100 vis: make r handle special keys like <Tab> Unlike vim we do not respect `:set expandtab` here. Diffstat:
| M | main.c | | | 12 | ++++-------- |
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/main.c b/main.c @@ -1653,15 +1653,11 @@ static const char *replace(Vis *vis, const char *keys, const Arg *arg) { if (!next) return NULL; - char replacement[64]; - size_t len = next - keys; - if (len >= sizeof(replacement)) + char replacement[UTFmax+1]; + if (!vis_keys_utf8(vis, keys, replacement)) return next; - memcpy(replacement, keys, len); - replacement[len] = '\0'; - - if (strcmp("<Escape>", replacement) == 0) + if (replacement[0] == 0x1b) /* <Escape> */ return next; if (vis_mode_get(vis) == VIS_MODE_NORMAL) { @@ -1669,7 +1665,7 @@ static const char *replace(Vis *vis, const char *keys, const Arg *arg) { vis_operator(vis, VIS_OP_CHANGE); vis_motion(vis, VIS_MOVE_CHAR_NEXT); for (; count > 0; count--) - vis_keys_feed(vis, replacement); + vis_keys_feed(vis, replacement[0] == '\n' ? "<Enter>" : replacement); } else { vis_operator(vis, VIS_OP_REPLACE, replacement); }