Add zero-indexed register
This commit is contained in:
parent
f94e8e49ed
commit
ad9a4b25d5
|
@ -198,6 +198,7 @@ constexpr StringView register_doc =
|
|||
"%: buffer name\n"
|
||||
".: selection contents\n"
|
||||
"#: selection index\n"
|
||||
"$: selection index (zero-indexed)\n"
|
||||
"_: null register\n"
|
||||
"\": default yank/paste register\n"
|
||||
"@: default macro register\n"
|
||||
|
|
11
src/main.cc
11
src/main.cc
|
@ -436,6 +436,17 @@ void register_registers()
|
|||
return res;
|
||||
}));
|
||||
|
||||
register_manager.add_register('$', make_dyn_reg(
|
||||
"$",
|
||||
[](const Context& context) {
|
||||
const size_t count = context.selections().size();
|
||||
StringList res;
|
||||
res.reserve(count);
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
res.push_back(to_string((int)i));
|
||||
return res;
|
||||
}));
|
||||
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
register_manager.add_register('0'+i, make_dyn_reg(
|
||||
|
|
|
@ -67,6 +67,7 @@ static const HashMap<StringView, Codepoint> reg_names {
|
|||
{ "percent", '%' },
|
||||
{ "dot", '.' },
|
||||
{ "hash", '#' },
|
||||
{ "dollar", '$' },
|
||||
{ "underscore", '_' },
|
||||
{ "colon", ':' }
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user