From 6e5ff644f273dc561cef0308c79a532bdaeef0ea Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 2 Oct 2013 19:10:31 +0100 Subject: [PATCH] add for rotating selections content --- README.asciidoc | 5 ++++- src/normal.cc | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index b6783067..d9fede30 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -80,10 +80,11 @@ Basic Movement * _N_: add a new selection with next match * _alt-n_: replace main selection with next match (preserving the others) - * _alt-c_: center main selection in current window * _pageup_: scroll up * _pagedown_: scroll down + * _alt-r_: rotate selections (the main selection becomes the next one) + Appending --------- @@ -141,6 +142,8 @@ Changes * _~_: to upper case * _alt-`_: swap case + * _alt-R_: rotate selections content + Goto Commands ------------- diff --git a/src/normal.cc b/src/normal.cc index 768801c4..1390108e 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -658,6 +658,19 @@ void rotate_selections(Context& context) context.editor().rotate_selections(count); } +void rotate_selections_content(Context& context) +{ + int count = context.numeric_param(); + if (count == 0) + count = 1; + Editor& editor = context.editor(); + auto strings = editor.selections_content(); + count = count % strings.size(); + std::rotate(strings.begin(), strings.end()-count, strings.end()); + editor.insert(strings, InsertMode::Replace); + editor.rotate_selections(count); +} + enum class SelectFlags { None = 0, @@ -951,6 +964,7 @@ KeyMap keymap = { { Key::Modifiers::Control, 's' }, save_selections }, { { Key::Modifiers::Alt, 'r' }, rotate_selections }, + { { Key::Modifiers::Alt, 'R' }, rotate_selections_content }, { { Key::Modifiers::None, 'q' }, start_or_end_macro_recording }, { { Key::Modifiers::None, 'Q' }, replay_macro },