summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-12-24 16:48:52 +0000
committerMaxime Coste <frrrwww@gmail.com>2013-12-24 16:48:52 +0000
commit983abefc30facb1b30d6bed1ee91b71e5602042d (patch)
tree8caf8231b4ce0ebf1ff970d7cd6ffc25cdabd52c /src/normal.cc
parentfd17ea00ddbb50118bcca0b3d5c431888e30105b (diff)
Add alt-| for piping and appending rather than replacing
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/normal.cc b/src/normal.cc
index d042d9fa..4922b70f 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -418,6 +418,7 @@ void command(Context& context, int)
});
}
+template<InsertMode mode>
void pipe(Context& context, int)
{
auto completer = [](const Context& context, CompletionFlags flags,
@@ -450,7 +451,8 @@ void pipe(Context& context, int)
return completions;
};
- context.input_handler().prompt("pipe:", get_color("Prompt"), completer,
+ const char* prompt = mode == InsertMode::Replace ? "pipe:" : "pipe (ins):";
+ context.input_handler().prompt(prompt, get_color("Prompt"), completer,
[](const String& cmdline, PromptEvent event, Context& context)
{
if (event != PromptEvent::Validate)
@@ -484,7 +486,7 @@ void pipe(Context& context, int)
strings.push_back(str);
}
ScopedEdition edition(context);
- insert<InsertMode::Replace>(buffer, selections, strings);
+ insert<mode>(buffer, selections, strings);
});
}
@@ -1280,7 +1282,8 @@ KeyMap keymap =
{ '%', [](Context& context, int) { select_whole_buffer(context.buffer(), context.selections()); } },
{ ':', command },
- { '|', pipe },
+ { '|', pipe<InsertMode::Replace> },
+ { alt('|'), pipe<InsertMode::Append> },
{ ' ', [](Context& context, int count) { if (count == 0) clear_selections(context.buffer(), context.selections());
else keep_selection(context.selections(), count-1); } },
{ alt(' '), [](Context& context, int count) { if (count == 0) flip_selections(context.selections());