From 706c1672d52967e7dd6ad9d92c4dfa3a6f15744e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 13 Nov 2017 17:36:04 +0800 Subject: [PATCH] Normal: add to select first and last char of selection Fixes #550 --- doc/pages/keys.asciidoc | 7 +++++-- src/normal.cc | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/pages/keys.asciidoc b/doc/pages/keys.asciidoc index 85588b39..d66a6b73 100644 --- a/doc/pages/keys.asciidoc +++ b/doc/pages/keys.asciidoc @@ -513,11 +513,14 @@ to skim through the jump list using: *s*:: create a selection +*S*:: + split the current selection + **:: split the current selections on line boundaries -*S*:: - split the current selection +**:: + select first and last characters of each selections *C*:: copy the current selection to the next line diff --git a/src/normal.cc b/src/normal.cc index 9a407ec1..1166ae30 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -932,6 +932,19 @@ void split_lines(Context& context, NormalParams) selections = std::move(res); } +void select_boundaries(Context& context, NormalParams) +{ + auto& selections = context.selections(); + Vector res; + for (auto& sel : selections) + { + res.push_back(sel.min()); + if (sel.min() != sel.max()) + res.push_back(sel.max()); + } + selections = std::move(res); +} + void join_lines_select_spaces(Context& context, NormalParams) { auto& buffer = context.buffer(); @@ -2011,6 +2024,7 @@ static const HashMap key { {'s'}, {"select regex matches in selected text", select_regex} }, { {'S'}, {"split selected text on regex matches", split_regex} }, { {alt('s')}, {"split selected text on line ends", split_lines} }, + { {alt('S')}, {"select selection boundaries", select_boundaries} }, { {'.'}, {"repeat last insert command", repeat_last_insert} }, { {alt('.')}, {"repeat last object select/character find", repeat_last_select} },