From 75dd74ff43ba269bd62ff9b69d32f3fda2f511f9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 21 Jun 2015 18:58:35 +0100 Subject: [PATCH] Use as replace paste all yanked selections Move rotate to ' and rotate contents to Fix segfault when pasting all and nothing was yanked yet --- README.asciidoc | 6 +++--- doc/keymap | 2 +- src/normal.cc | 13 +++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index 02d10973..5f865547 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -243,7 +243,7 @@ Movement * `pageup`: scroll up * `pagedown`: scroll down - * `alt-r`: rotate selections (the main selection becomes the next one) + * `'`: rotate selections (the main selection becomes the next one) * `;`: reduce selections to their cursor * `alt-;`: flip the selections direction @@ -329,8 +329,8 @@ Changes * `alt-@`: convert spaces to tabs in current selections, uses the buffer tabstop option or the count parameter for tabstop. - * `alt-R`: rotate selections content, if specified, the count groups - selections, so `3` rotate (1, 2, 3) and (3, 4, 6) + * `alt-'`: rotate selections content, if specified, the count groups + selections, so `3` rotate (1, 2, 3) and (3, 4, 6) independently. Goto Commands diff --git a/doc/keymap b/doc/keymap index 1d537f06..02217e6e 100644 --- a/doc/keymap +++ b/doc/keymap @@ -9,7 +9,7 @@ ┣━━━━━━━━━━━┻━┱─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┺━┓ ┃ ┃ ⇬ ┃ APPEND│ split│ │ ᵐʳ│ ᵐᵍ│ ᵐˡ│ ᵐ│ ᵐ│ ᵐˡ│cmdline│use reg│ pipe┃ ┃ ┃ ┠┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ find│ goto │ │ │ │ ├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃ -┃ ┃ append│ select│ delete│ char│ │ ← │ ↓ │ ↑ │ → │ cursor│ │eschook┃ ┃ +┃ ┃ append│ select│ delete│ char│ │ ← │ ↓ │ ↑ │ → │ cursor│ rotate│eschook┃ ┃ ┣━━━━━━━━━┳━━━┹───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┲━━━┷━━━━━━━┻━━━━━━━━┫ ┃ ┃ indent│ │ ᵐ│copysel│ ᵛ│ ᵐʷ│ ᵐʳ│ │ dedent│ indent│ ᵐʳ┃ ┃ ┃ ┠┄┄┄┄┄┄┄┤ │ select├┄┄┄┄┄┄┄┤ view│ prev│ search│ match├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ search┃ ┃ diff --git a/src/normal.cc b/src/normal.cc index 6a936f82..84724b11 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -533,7 +533,10 @@ void paste_all(Context& context, NormalParams params) Vector offsets; for (auto& str : strings) { - if (not str.empty() and str.back() == '\n') + if (str.empty()) + continue; + + if (str.back() == '\n') effective_mode = adapt_for_linewise(mode); all += str; offsets.push_back(all.length()); @@ -557,7 +560,8 @@ void paste_all(Context& context, NormalParams params) pos = offset; } } - selections = std::move(result); + if (not result.empty()) + selections = std::move(result); } template @@ -1463,6 +1467,7 @@ static NormalCmdDesc cmds[] = { alt('p'), "paste every yanked selection after selected text", paste_all }, { alt('P'), "paste every yanked selection before selected text", paste_all }, { 'R', "replace selected text with yanked text", paste }, + { alt('R'), "replace selected text with yanked text", paste_all }, { 's', "select regex matches in selected text", select_regex }, { 'S', "split selected text on regex matches", split_regex }, @@ -1554,8 +1559,8 @@ static NormalCmdDesc cmds[] = { ctrl('o'), "jump backward in jump list", jump }, { ctrl('s'), "push current selections in jump list", save_selections }, - { alt('r'), "rotate main selection", rotate_selections }, - { alt('R'), "rotate selections content", rotate_selections_content }, + { '\'', "rotate main selection", rotate_selections }, + { alt('\''), "rotate selections content", rotate_selections_content }, { 'q', "replay recorded macro", replay_macro }, { 'Q', "start or end macro recording", start_or_end_macro_recording },