From b59a0816b94b0c3f90b12304b8d6869f8a402744 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 26 Nov 2011 19:11:24 +0000 Subject: [PATCH] Add wq and wq! commands --- src/main.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cc b/src/main.cc index 8919d24d..9cddfb9f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -414,6 +414,13 @@ void quit(const CommandParameters& params, const Context& context) quit_requested = true; } +template +void write_and_quit(const CommandParameters& params, const Context& context) +{ + write_buffer(params, context); + quit(CommandParameters(), context); +} + void show_buffer(const CommandParameters& params, const Context& context) { if (params.size() != 1) @@ -664,6 +671,8 @@ int main(int argc, char* argv[]) command_manager.register_command(std::vector{ "q!", "quit!" }, quit); command_manager.register_command(std::vector{ "w", "write" }, write_buffer, PerArgumentCommandCompleter{ complete_filename }); + command_manager.register_command(std::vector{ "wq" }, write_and_quit); + command_manager.register_command(std::vector{ "wq!" }, write_and_quit); command_manager.register_command(std::vector{ "b", "buffer" }, show_buffer, PerArgumentCommandCompleter { std::bind(&BufferManager::complete_buffername, &buffer_manager, _1, _2)