diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-11-03 17:00:41 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-11-03 17:03:40 +0100 |
| commit | ce73d7983ae57784d269d15b0e663d8ff03c8b4d (patch) | |
| tree | fde35140a66908ea1ecad468ec2be507bf61dcee | |
| parent | ce14602c3bd22b1b2793da18dda49f921c72cf88 (diff) | |
| download | vis-ce73d7983ae57784d269d15b0e663d8ff03c8b4d.tar.gz vis-ce73d7983ae57784d269d15b0e663d8ff03c8b4d.tar.xz | |
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
| -rw-r--r-- | main.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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, "<Enter>"); } else { vis_motion(vis, MOVE_LINE_BEGIN); - vis_insert_nl(vis); - vis_motion(vis, MOVE_LINE_PREV); + vis_keys_inject(vis, keys, "<Enter><Up>"); } - vis_mode_switch(vis, VIS_MODE_INSERT); return keys; } |
