diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-03-27 23:25:30 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-03-28 12:25:06 +0200 |
| commit | 7a8633966797c524849fda6c69344ed3d4d58474 (patch) | |
| tree | 8a94cef513be2ff8e64cf43b5e7957c9b68cdda2 | |
| parent | 6331bf38783810a01a233ac73fa94ed028a0e965 (diff) | |
| download | vis-7a8633966797c524849fda6c69344ed3d4d58474.tar.gz vis-7a8633966797c524849fda6c69344ed3d4d58474.tar.xz | |
vis: let Meta-Ctrl-{j,k} create new cursor
on the line above/below the first/last existing cursor.
| -rw-r--r-- | config.def.h | 2 | ||||
| -rw-r--r-- | main.c | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index 827fb0c..b773f72 100644 --- a/config.def.h +++ b/config.def.h @@ -177,7 +177,9 @@ static const KeyBinding bindings_normal[] = { { "<C-c>", ALIAS("<Escape>") }, { "<Delete>", ALIAS("x") }, { "<C-k>", ACTION(CURSORS_NEW_LINE_ABOVE) }, + { "<M-C-k>", ACTION(CURSORS_NEW_LINE_ABOVE_FIRST) }, { "<C-j>", ACTION(CURSORS_NEW_LINE_BELOW) }, + { "<M-C-j>", ACTION(CURSORS_NEW_LINE_BELOW_LAST) }, { "<Tab>", ACTION(CURSORS_ALIGN) }, { "<C-n>", ACTION(CURSOR_SELECT_WORD) }, { "<C-p>", ACTION(CURSORS_REMOVE_LAST) }, @@ -237,7 +237,9 @@ enum { VIS_ACTION_PUT_BEFORE_END, VIS_ACTION_CURSOR_SELECT_WORD, VIS_ACTION_CURSORS_NEW_LINE_ABOVE, + VIS_ACTION_CURSORS_NEW_LINE_ABOVE_FIRST, VIS_ACTION_CURSORS_NEW_LINE_BELOW, + VIS_ACTION_CURSORS_NEW_LINE_BELOW_LAST, VIS_ACTION_CURSORS_NEW_LINES_BEGIN, VIS_ACTION_CURSORS_NEW_LINES_END, VIS_ACTION_CURSORS_NEW_MATCH_NEXT, @@ -888,11 +890,21 @@ static const KeyAction vis_action[] = { "Create a new cursor on the line above", cursors_new, { .i = -1 } }, + [VIS_ACTION_CURSORS_NEW_LINE_ABOVE_FIRST] = { + "cursors-new-lines-above-first", + "Create a new cursor on the line above the first cursor", + cursors_new, { .i = INT_MIN } + }, [VIS_ACTION_CURSORS_NEW_LINE_BELOW] = { "cursor-new-lines-below", "Create a new cursor on the line below", cursors_new, { .i = +1 } }, + [VIS_ACTION_CURSORS_NEW_LINE_BELOW_LAST] = { + "cursor-new-lines-below-last", + "Create a new cursor on the line below the last cursor", + cursors_new, { .i = INT_MAX } + }, [VIS_ACTION_CURSORS_NEW_LINES_BEGIN] = { "cursors-new-lines-begin", "Create a new cursor at the start of every line covered by selection", @@ -1190,7 +1202,22 @@ static const char *repeat(Vis *vis, const char *keys, const Arg *arg) { static const char *cursors_new(Vis *vis, const char *keys, const Arg *arg) { View *view = vis_view(vis); - Cursor *cursor = view_cursors_primary_get(view); + Cursor *cursor; + switch (arg->i) { + case -1: + case +1: + cursor = view_cursors_primary_get(view); + break; + case INT_MIN: + cursor = view_cursors(view); + break; + case INT_MAX: + for (Cursor *c = view_cursors(view); c; c = view_cursors_next(c)) + cursor = c; + break; + default: + return keys; + } size_t oldpos = view_cursors_pos(cursor); if (arg->i > 0) view_line_down(cursor); |
