From 5c74f98757371560bda5f6c0816f93d94e099eb7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 22 Feb 2013 18:37:34 +0100 Subject: [PATCH] Use S for regex splitting, and alt-s for line splitting --- README.asciidoc | 10 ++++++++-- src/main.cc | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index f45de173..3a2a381f 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -137,9 +137,15 @@ select the paragraph with enough _x_. press _s_ and enter roger then enter. now paragraph selection was replaced with multiselection of each roger in the paragraph. press _c_ and marcel to replace rogers with marcels. -A multiselection can also be obtained with _Alt-s_, which splits the current +A multiselection can also be obtained with _S_, which splits the current selection according to the regex entered. To split a comma separated list, -use _alt-s_ then ', *' +use _S_ then ', *' + +_s_ and _S_ share the search pattern with _/_, and hence entering an empty +pattern uses the last one. + +As a convenience, _alt-s_ allows you to split the current selections on +line boundaries. To clear multiple selections, use _space_. To keep only the nth selection use _n_ followed by _space_, to remove only the nth selection, use _n_ diff --git a/src/main.cc b/src/main.cc index 4a4a6bb8..12f33e45 100644 --- a/src/main.cc +++ b/src/main.cc @@ -300,6 +300,11 @@ void do_split_regex(Context& context) }); } +void do_split_lines(Context& context) +{ + context.editor().multi_select(std::bind(split_selection, _1, "^")); +} + void do_join(Context& context) { Editor& editor = context.editor(); @@ -588,6 +593,8 @@ std::unordered_map> keymap = { { Key::Modifiers::Alt, 'p' }, do_paste }, { { Key::Modifiers::None, 's' }, do_select_regex }, + { { Key::Modifiers::None, 'S' }, do_split_regex }, + { { Key::Modifiers::Alt, 's' }, do_split_lines }, { { Key::Modifiers::None, '.' }, do_repeat_insert }, @@ -641,8 +648,6 @@ std::unordered_map> keymap = { { Key::Modifiers::Alt, 'h' }, repeated(select(select_to_eol_reverse)) }, { { Key::Modifiers::Alt, 'H' }, repeated(select(select_to_eol_reverse)) }, - { { Key::Modifiers::Alt, 's' }, do_split_regex }, - { { Key::Modifiers::Alt, 'j' }, do_join }, { { Key::Modifiers::None, '<' }, do_deindent },