diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-08-02 12:21:13 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-08-02 12:21:13 +0200 |
| commit | c56f3a4c6cf667453ca5b867d567e5688e37072f (patch) | |
| tree | 5bca3ce763c2532e5a52702c43e974593524b272 | |
| parent | 370a94f6931a7e325ef1b23f0c15996c672ee587 (diff) | |
| download | vis-c56f3a4c6cf667453ca5b867d567e5688e37072f.tar.gz vis-c56f3a4c6cf667453ca5b867d567e5688e37072f.tar.xz | |
vis: use I and A instead of CTRL-O for new cursors in visual mode
I and A creates a new cursor at start/end of every selected line.
| -rw-r--r-- | config.def.h | 3 | ||||
| -rw-r--r-- | vis.c | 18 |
2 files changed, 18 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h index a2eabee..3736833 100644 --- a/config.def.h +++ b/config.def.h @@ -436,9 +436,10 @@ static KeyBinding vis_mode_visual[] = { { { CONTROL('N') }, cursors_select_next, { } }, { { CONTROL('X') }, cursors_select_skip, { } }, { { CONTROL('P') }, cursors_remove, { } }, + { { NONE('I') }, cursors_split, { .i = -1 } }, + { { NONE('A') }, cursors_split, { .i = +1 } }, { { KEY(BACKSPACE) }, operator, { .i = OP_DELETE } }, { { KEY(DELETE) }, operator, { .i = OP_DELETE } }, - { { CONTROL('O') }, operator, { .i = OP_CURSOR } }, { { NONE(ESC) }, switchmode, { .i = VIS_MODE_NORMAL } }, { { CONTROL('c') }, switchmode, { .i = VIS_MODE_NORMAL } }, { { NONE('v') }, switchmode, { .i = VIS_MODE_NORMAL } }, @@ -326,6 +326,9 @@ static void totill_reverse(const Arg *arg); static void replace(const Arg *arg); /* create a new cursor on the previous (arg->i < 0) or next (arg->i > 0) line */ static void cursors_new(const Arg *arg); +/* create new cursors in visual mode either at the start (arg-i < 0) + * or end (arg->i > 0) of the selected lines */ +static void cursors_split(const Arg *arg); /* try to align all cursors on the same column */ static void cursors_align(const Arg *arg); /* remove all but the primary cursor and their selections */ @@ -595,8 +598,14 @@ static size_t op_cursor(OperatorContext *c) { Filerange r = text_range_linewise(txt, &c->range); for (size_t line = text_range_line_first(txt, &r); line != EPOS; line = text_range_line_next(txt, &r, line)) { Cursor *cursor = view_cursors_new(view); - if (cursor) - view_cursors_to(cursor, text_line_start(txt, line)); + if (cursor) { + size_t pos; + if (c->arg->i > 0) + pos = text_line_finish(txt, line); + else + pos = text_line_start(txt, line); + view_cursors_to(cursor, pos); + } } return EPOS; } @@ -857,6 +866,11 @@ static void cursors_new(const Arg *arg) { view_cursors_to(cursor, pos); } +static void cursors_split(const Arg *arg) { + vis->action.arg = *arg; + operator(&(const Arg){ .i = OP_CURSOR }); +} + static void cursors_align(const Arg *arg) { View *view = vis->win->view; Text *txt = vis->win->file->text; |
