From ce73d7983ae57784d269d15b0e663d8ff03c8b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 3 Nov 2015 17:00:41 +0100 Subject: vis: make open line commands (o and O) repeatable The implementation of O is a bit of a hack and has a few issues: - does not respect auto indentation settings - does not meaningfully repeat when given a count --- main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 36b9bcd..9d6cd10 100644 --- a/main.c +++ b/main.c @@ -753,12 +753,12 @@ static KeyAction vis_action[] = { [VIS_ACTION_OPEN_LINE_ABOVE] = { "open-line-above", "Begin a new line above the cursor", - openline, { .i = MOVE_LINE_PREV } + openline, { .i = -1 } }, [VIS_ACTION_OPEN_LINE_BELOW] = { "open-line-below", "Begin a new line below the cursor", - openline, { .i = MOVE_LINE_NEXT } + openline, { .i = +1 } }, [VIS_ACTION_JOIN_LINE_BELOW] = { "join-line-below", @@ -1515,15 +1515,14 @@ static const char *window(Vis *vis, const char *keys, const Arg *arg) { } static const char *openline(Vis *vis, const char *keys, const Arg *arg) { - if (arg->i == MOVE_LINE_NEXT) { + vis_operator(vis, OP_INSERT); + if (arg->i > 0) { vis_motion(vis, MOVE_LINE_END); - vis_insert_nl(vis); + vis_keys_inject(vis, keys, ""); } else { vis_motion(vis, MOVE_LINE_BEGIN); - vis_insert_nl(vis); - vis_motion(vis, MOVE_LINE_PREV); + vis_keys_inject(vis, keys, ""); } - vis_mode_switch(vis, VIS_MODE_INSERT); return keys; } -- cgit v1.2.3