diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-06-15 10:20:23 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-06-15 15:51:43 +0200 |
| commit | 4b1ea2d7ca3ba092177a92729428d7252812edb7 (patch) | |
| tree | d3933aca3881a978c0275b2ea1814cfbdefd5602 /main.c | |
| parent | c0dbe69c034f7a78ad8de87491dc5df36bcb5ab4 (diff) | |
| download | vis-4b1ea2d7ca3ba092177a92729428d7252812edb7.tar.gz vis-4b1ea2d7ca3ba092177a92729428d7252812edb7.tar.xz | |
vis: allow active selection to be saved to a register
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -74,6 +74,8 @@ static const char *cursors_select_skip(Vis*, const char *keys, const Arg *arg); static const char *selections_rotate(Vis*, const char *keys, const Arg *arg); /* remove leading and trailing white spaces from selections */ static const char *selections_trim(Vis*, const char *keys, const Arg *arg); +/* save active selections to register */ +static const char *selections_save(Vis*, const char *keys, const Arg *arg); /* adjust current used count according to keys */ static const char *count(Vis*, const char *keys, const Arg *arg); /* move to the count-th line or if not given either to the first (arg->i < 0) @@ -276,6 +278,7 @@ enum { VIS_ACTION_SELECTIONS_ROTATE_LEFT, VIS_ACTION_SELECTIONS_ROTATE_RIGHT, VIS_ACTION_SELECTIONS_TRIM, + VIS_ACTION_SELECTIONS_SAVE, VIS_ACTION_TEXT_OBJECT_WORD_OUTER, VIS_ACTION_TEXT_OBJECT_WORD_INNER, VIS_ACTION_TEXT_OBJECT_LONGWORD_OUTER, @@ -1036,6 +1039,11 @@ static const KeyAction vis_action[] = { VIS_HELP("Remove leading and trailing white space from selections") selections_trim }, + [VIS_ACTION_SELECTIONS_SAVE] = { + "vis-selections-save", + VIS_HELP("Save currently active selections to register") + selections_save + }, [VIS_ACTION_TEXT_OBJECT_WORD_OUTER] = { "vis-textobject-word-outer", VIS_HELP("A word leading and trailing whitespace included") @@ -1576,6 +1584,16 @@ static const char *selections_trim(Vis *vis, const char *keys, const Arg *arg) { return keys; } +static const char *selections_save(Vis *vis, const char *keys, const Arg *arg) { + View *view = vis_view(vis); + enum VisRegister reg = vis_register_used(vis); + Array sel = view_selections_get_all(view); + vis_register_selections_set(vis, reg, &sel); + array_release(&sel); + vis_cancel(vis); + return keys; +} + static const char *replace(Vis *vis, const char *keys, const Arg *arg) { if (!keys[0]) { vis_keymap_disable(vis); |
