vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 8d5754add941fda8772b91773c384242bd8b481a parent 1b8adfd3e01ea064d2af327f4e734036151cffd6 Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 3 Nov 2015 16:34:37 +0100 vis: make single character replace (r command) repeatable Diffstat:
| M | main.c | | | 16 | +++++++++------- |
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/main.c b/main.c @@ -1195,14 +1195,16 @@ static const char *replace(Vis *vis, const char *keys, const Arg *arg) { if (!keys[0]) return NULL; const char *next = vis_key_next(vis, keys); + if (!next) + return NULL; size_t len = next - keys; - /* TODO: fix - action_reset(vis, &vis->action_prev); - vis->action_prev.op = &ops[OP_REPEAT_REPLACE]; - buffer_put(&vis->buffer_repeat, keys, len); - */ - vis_replace_key(vis, keys, len); - text_snapshot(vis_text(vis)); + char key[len+1]; + memcpy(key, keys, len); + key[len] = '\0'; + vis_operator(vis, OP_REPLACE); + vis_motion(vis, MOVE_NOP); + vis_keys_inject(vis, next, key); + vis_keys_inject(vis, next+len, "<Escape>"); return next; }