aboutsummaryrefslogtreecommitdiff
path: root/vis.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-08-02 12:21:13 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-08-02 12:21:13 +0200
commitc56f3a4c6cf667453ca5b867d567e5688e37072f (patch)
tree5bca3ce763c2532e5a52702c43e974593524b272 /vis.c
parent370a94f6931a7e325ef1b23f0c15996c672ee587 (diff)
downloadvis-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.
Diffstat (limited to 'vis.c')
-rw-r--r--vis.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/vis.c b/vis.c
index ba2e94d..5b499ba 100644
--- a/vis.c
+++ b/vis.c
@@ -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;