Use <a-R> as replace paste all yanked selections

Move rotate to ' and rotate contents to <a-'>
Fix segfault when pasting all and nothing was yanked yet
This commit is contained in:
Maxime Coste 2015-06-21 18:58:35 +01:00
parent 64cbdcd328
commit 75dd74ff43
3 changed files with 13 additions and 8 deletions

View File

@ -243,7 +243,7 @@ Movement
* `pageup`: scroll up * `pageup`: scroll up
* `pagedown`: scroll down * `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 * `;`: reduce selections to their cursor
* `alt-;`: flip the selections direction * `alt-;`: flip the selections direction
@ -329,8 +329,8 @@ Changes
* `alt-@`: convert spaces to tabs in current selections, uses the buffer * `alt-@`: convert spaces to tabs in current selections, uses the buffer
tabstop option or the count parameter for tabstop. tabstop option or the count parameter for tabstop.
* `alt-R`: rotate selections content, if specified, the count groups * `alt-'`: rotate selections content, if specified, the count groups
selections, so `3<a-R>` rotate (1, 2, 3) and (3, 4, 6) selections, so `3<a-'>` rotate (1, 2, 3) and (3, 4, 6)
independently. independently.
Goto Commands Goto Commands

View File

@ -9,7 +9,7 @@
┣━━━━━━━━━━━┻━┱─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┺━┓ ┃ ┣━━━━━━━━━━━┻━┱─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┴─┬─────┺━┓ ┃
┃ ⇬ ┃ APPEND│ split│ │ ᵐʳ│ ᵐᵍ│ ᵐˡ│ ᵐ│ ᵐ│ ᵐˡ│cmdline│use reg│ pipe┃ ┃ ┃ ⇬ ┃ APPEND│ split│ │ ᵐʳ│ ᵐᵍ│ ᵐˡ│ ᵐ│ ᵐ│ ᵐˡ│cmdline│use reg│ pipe┃ ┃
┃ ┠┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ find│ goto │ │ │ │ ├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃ ┃ ┠┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ find│ goto │ │ │ │ ├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┨ ┃
┃ ┃ append│ select│ delete│ char│ │ ← │ ↓ │ ↑ │ → │ cursor│ │eschook┃ ┃ ┃ ┃ append│ select│ delete│ char│ │ ← │ ↓ │ ↑ │ → │ cursor│ rotate│eschook┃ ┃
┣━━━━━━━━━┳━━━┹───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┲━━━┷━━━━━━━┻━━━━━━━━┫ ┣━━━━━━━━━┳━━━┹───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┬───┴───┲━━━┷━━━━━━━┻━━━━━━━━┫
┃ ┃ indent│ │ ᵐ│copysel│ ᵛ│ ᵐʷ│ ᵐʳ│ │ dedent│ indent│ ᵐʳ┃ ┃ ┃ ┃ indent│ │ ᵐ│copysel│ ᵛ│ ᵐʷ│ ᵐʳ│ │ dedent│ indent│ ᵐʳ┃ ┃
┃ ┠┄┄┄┄┄┄┄┤ │ select├┄┄┄┄┄┄┄┤ view│ prev│ search│ match├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ search┃ ┃ ┃ ┠┄┄┄┄┄┄┄┤ │ select├┄┄┄┄┄┄┄┤ view│ prev│ search│ match├┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┤ search┃ ┃

View File

@ -533,7 +533,10 @@ void paste_all(Context& context, NormalParams params)
Vector<ByteCount> offsets; Vector<ByteCount> offsets;
for (auto& str : strings) 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); effective_mode = adapt_for_linewise(mode);
all += str; all += str;
offsets.push_back(all.length()); offsets.push_back(all.length());
@ -557,6 +560,7 @@ void paste_all(Context& context, NormalParams params)
pos = offset; pos = offset;
} }
} }
if (not result.empty())
selections = std::move(result); selections = std::move(result);
} }
@ -1463,6 +1467,7 @@ static NormalCmdDesc cmds[] =
{ alt('p'), "paste every yanked selection after selected text", paste_all<InsertMode::Append> }, { alt('p'), "paste every yanked selection after selected text", paste_all<InsertMode::Append> },
{ alt('P'), "paste every yanked selection before selected text", paste_all<InsertMode::Insert> }, { alt('P'), "paste every yanked selection before selected text", paste_all<InsertMode::Insert> },
{ 'R', "replace selected text with yanked text", paste<InsertMode::Replace> }, { 'R', "replace selected text with yanked text", paste<InsertMode::Replace> },
{ alt('R'), "replace selected text with yanked text", paste_all<InsertMode::Replace> },
{ 's', "select regex matches in selected text", select_regex }, { 's', "select regex matches in selected text", select_regex },
{ 'S', "split selected text on regex matches", split_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<Backward> }, { ctrl('o'), "jump backward in jump list", jump<Backward> },
{ ctrl('s'), "push current selections in jump list", save_selections }, { ctrl('s'), "push current selections in jump list", save_selections },
{ alt('r'), "rotate main selection", rotate_selections }, { '\'', "rotate main selection", rotate_selections },
{ alt('R'), "rotate selections content", rotate_selections_content }, { alt('\''), "rotate selections content", rotate_selections_content },
{ 'q', "replay recorded macro", replay_macro }, { 'q', "replay recorded macro", replay_macro },
{ 'Q', "start or end macro recording", start_or_end_macro_recording }, { 'Q', "start or end macro recording", start_or_end_macro_recording },