diff options
| author | Marcel Rodrigues <marcelgmr@gmail.com> | 2015-03-24 16:18:22 -0300 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-03-24 21:37:29 +0100 |
| commit | 892596f8affa5451ab0839ef57b9cb7bf0e6d037 (patch) | |
| tree | fa51bda54a2e64cc754300f0ef4c3a0f673b7dfd | |
| parent | 426fd946bb609b787e828a89546ba9961b9b864d (diff) | |
| download | vis-892596f8affa5451ab0839ef57b9cb7bf0e6d037.tar.gz vis-892596f8affa5451ab0839ef57b9cb7bf0e6d037.tar.xz | |
Implement 'o' in visual mode: go to other end of selection.
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index a0876be..88b6a67 100644 --- a/config.def.h +++ b/config.def.h @@ -447,6 +447,7 @@ static KeyBinding vis_mode_visual[] = { { { NONE('r') }, operator, { .i = OP_CHANGE } }, { { NONE('s') }, operator, { .i = OP_CHANGE } }, { { NONE('J') }, operator, { .i = OP_JOIN } }, + { { NONE('o') }, selection_end, { NULL } }, { /* empty last element, array terminator */ }, }; @@ -448,6 +448,8 @@ static void movement_key(const Arg *arg); static void movement(const Arg *arg); /* let the current operator affect the range indicated by the text object arg->i */ static void textobj(const Arg *arg); +/* move to the other end of selected text */ +static void selection_end(const Arg *arg); /* use register indicated by arg->i for the current operator */ static void reg(const Arg *arg); /* perform a movement to mark arg->i */ @@ -958,6 +960,20 @@ static void textobj(const Arg *arg) { action_do(&action); } +static void selection_end(const Arg *arg) { + size_t pos = window_cursor_get(vis->win->win); + Filerange sel = window_selection_get(vis->win->win); + if (pos == sel.start) { + pos = text_char_prev(vis->win->text, sel.end); + } else { + pos = sel.start; + sel.start = text_char_prev(vis->win->text, sel.end); + sel.end = pos; + } + window_selection_set(vis->win->win, &sel); + window_cursor_to(vis->win->win, pos); +} + static void reg(const Arg *arg) { action.reg = &vis->registers[arg->i]; } |
