summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-02-22 18:45:27 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-02-22 18:45:27 +0100
commit77dc9955d3920d0bb6441f7956197ba6722b44e9 (patch)
treeb38bd4bb26aa14e452ef37a071807ecdad78e340 /src
parent4b11f73f1e8f15ccf24339637c1f0fc5d2bb56b7 (diff)
Paste: use count for repetition
Diffstat (limited to 'src')
-rw-r--r--src/main.cc25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/main.cc b/src/main.cc
index 12f33e45..9c26c7ba 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -242,28 +242,17 @@ template<InsertMode insert_mode>
void do_paste(Context& context)
{
Editor& editor = context.editor();
- int count = context.numeric_param();
auto strings = RegisterManager::instance()['"'].values(context);
InsertMode mode = insert_mode;
- if (count == 0)
+ for (auto& str : strings)
{
- for (auto& str : strings)
- {
- if (not str.empty() and str.back() == '\n')
- {
- mode = adapt_for_linewise(mode);
- break;
- }
- }
- editor.insert(strings, mode);
- }
- else if (count <= strings.size())
- {
- auto& str = strings[count-1];
if (not str.empty() and str.back() == '\n')
+ {
mode = adapt_for_linewise(mode);
- editor.insert(str, mode);
+ break;
+ }
}
+ editor.insert(strings, mode);
}
void do_select_regex(Context& context)
@@ -588,8 +577,8 @@ std::unordered_map<Key, std::function<void (Context& context)>> keymap =
{ { Key::Modifiers::None, 'G' }, do_go<SelectMode::Extend> },
{ { Key::Modifiers::None, 'y' }, do_yank },
- { { Key::Modifiers::None, 'p' }, do_paste<InsertMode::Append> },
- { { Key::Modifiers::None, 'P' }, do_paste<InsertMode::Insert> },
+ { { Key::Modifiers::None, 'p' }, repeated(do_paste<InsertMode::Append>) },
+ { { Key::Modifiers::None, 'P' }, repeated(do_paste<InsertMode::Insert>) },
{ { Key::Modifiers::Alt, 'p' }, do_paste<InsertMode::Replace> },
{ { Key::Modifiers::None, 's' }, do_select_regex },