diff --git a/src/commands.cc b/src/commands.cc index 1f2aa3d3..faf399c9 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -282,6 +282,21 @@ void write_buffer(const CommandParameters& params, Context& context) buffer.notify_saved(); } +void write_all_buffers(const CommandParameters& params, Context& context) +{ + if (params.size() != 0) + throw wrong_argument_count(); + + for (auto& buffer : BufferManager::instance()) + { + if (buffer->type() != Buffer::Type::Scratch and buffer->is_modified()) + { + write_buffer_to_file(*buffer, buffer->name()); + buffer->notify_saved(); + } + } +} + template void quit(const CommandParameters& params, Context& context) { @@ -758,6 +773,7 @@ void register_commands() cm.register_commands({ "e", "edit" }, edit, filename_completer); cm.register_commands({ "e!", "edit!" }, edit, filename_completer); cm.register_commands({ "w", "write" }, write_buffer, filename_completer); + cm.register_commands({ "wa", "writeall" }, write_all_buffers); cm.register_commands({ "q", "quit" }, quit); cm.register_commands({ "q!", "quit!" }, quit); cm.register_command("wq", write_and_quit);