summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-11-26 13:36:26 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-11-26 13:36:26 +0000
commitf66bbdf209b428aededcb36d2080d4cef86648ab (patch)
tree5d4f0564e4e8ad5af48d3d7c10d188e22f49057c /src/normal.cc
parentbf7d3a4fec59cc17288fc7a673574aa66d08e0dc (diff)
select/split interpret count parameter as the capture group to use
count being 0 by default, we use the whole match, but we can now specify to use capture 1 with 1s<regex><ret>.
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/normal.cc b/src/normal.cc
index 009a2224..54b062c1 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -704,26 +704,28 @@ void use_selection_as_search_pattern(Context& context, NormalParams params)
void select_regex(Context& context, NormalParams params)
{
const char reg = to_lower(params.reg ? params.reg : '/');
- regex_prompt(context, "select:", [reg](Regex ex, PromptEvent event, Context& context) {
+ unsigned capture = (unsigned)params.count;
+ regex_prompt(context, "select:", [reg, capture](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value(reg)};
else if (event == PromptEvent::Validate)
RegisterManager::instance()[reg] = ex.str();
if (not ex.empty() and not ex.str().empty())
- select_all_matches(context.selections(), ex);
+ select_all_matches(context.selections(), ex, capture);
});
}
void split_regex(Context& context, NormalParams params)
{
const char reg = to_lower(params.reg ? params.reg : '/');
- regex_prompt(context, "split:", [reg](Regex ex, PromptEvent event, Context& context) {
+ unsigned capture = (unsigned)params.count;
+ regex_prompt(context, "split:", [reg, capture](Regex ex, PromptEvent event, Context& context) {
if (ex.empty())
ex = Regex{context.main_sel_register_value(reg)};
else if (event == PromptEvent::Validate)
RegisterManager::instance()[reg] = ex.str();
if (not ex.empty() and not ex.str().empty())
- split_selections(context.selections(), ex);
+ split_selections(context.selections(), ex, capture);
});
}