diff options
| -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); |
