Skip to content

Commit

Permalink
Normal: add <a-S> to select first and last char of selection
Browse files Browse the repository at this point in the history
Fixes #550
  • Loading branch information
mawww committed Nov 13, 2017
1 parent 5f5188a commit 706c167
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/pages/keys.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,14 @@ to skim through the jump list using:
*s*::
create a selection

*S*::
split the current selection

*<a-s>*::
split the current selections on line boundaries

*S*::
split the current selection
*<a-S>*::
select first and last characters of each selections

*C*::
copy the current selection to the next line
Expand Down
14 changes: 14 additions & 0 deletions src/normal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Selection> 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();
Expand Down Expand Up @@ -2011,6 +2024,7 @@ static const HashMap<Key, NormalCmd, MemoryDomain::Undefined, KeymapBackend> 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} },
Expand Down

1 comment on commit 706c167

@nochiel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @mawww!

Please sign in to comment.