Use S for regex splitting, and alt-s for line splitting

This commit is contained in:
Maxime Coste 2013-02-22 18:37:34 +01:00
parent 5f446d9aec
commit 5c74f98757
2 changed files with 15 additions and 4 deletions

View File

@ -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<esc> 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_

View File

@ -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<Key, std::function<void (Context& context)>> keymap =
{ { Key::Modifiers::Alt, 'p' }, do_paste<InsertMode::Replace> },
{ { 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<Key, std::function<void (Context& context)>> keymap =
{ { Key::Modifiers::Alt, 'h' }, repeated(select<SelectMode::Replace>(select_to_eol_reverse)) },
{ { Key::Modifiers::Alt, 'H' }, repeated(select<SelectMode::Extend>(select_to_eol_reverse)) },
{ { Key::Modifiers::Alt, 's' }, do_split_regex },
{ { Key::Modifiers::Alt, 'j' }, do_join },
{ { Key::Modifiers::None, '<' }, do_deindent },