@@ -1086,6 +1086,36 @@ mod cmd {
10861086 _write_all(editor, args, event, true, true)
10871087 }
10881088
1089+ fn _quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent, force: bool) {
1090+ if !force {
1091+ // check if there are some unsaved buffers
1092+ let modified = _modified_left(editor);
1093+ if !modified.is_empty() {
1094+ let err = format!(
1095+ "{} unsaved buffer(s) remaining: {:?}",
1096+ modified.len(),
1097+ modified
1098+ );
1099+ editor.set_error(err);
1100+ return;
1101+ }
1102+ }
1103+
1104+ // close all views
1105+ let views: Vec<_> = editor.tree.views().map(|(view, _)| view.id).collect();
1106+ for view_id in views {
1107+ editor.close(view_id, false);
1108+ }
1109+ }
1110+
1111+ fn quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1112+ _quit_all(editor, args, event, false)
1113+ }
1114+
1115+ fn force_quit_all(editor: &mut Editor, args: &[&str], event: PromptEvent) {
1116+ _quit_all(editor, args, event, true)
1117+ }
1118+
10891119 pub const COMMAND_LIST: &[Command] = &[
10901120 Command {
10911121 name: "quit",
@@ -1165,19 +1195,34 @@ mod cmd {
11651195 completer: None,
11661196 },
11671197 Command {
1168− name: "write-all-quit",
1169− alias: Some("waq"),
1198+ name: "write-quit-all",
1199+ alias: Some("wqa"),
11701200 doc: "Writes changes from all views to disk and close all views.",
11711201 fun: write_all_quit,
11721202 completer: None,
11731203 },
11741204 Command {
1175− name: "write-all-quit!",
1176− alias: Some("waq!"),
1177− doc: "Writes changes from all views to disk and close all views forcefully (ignoring errors).",
1205+ name: "write-quit-all!",
1206+ alias: Some("wqa!"),
1207+ doc: "Writes changes from all views to disk and close all views forcefully (ignoring unsaved changes).",
11781208 fun: force_write_all_quit,
11791209 completer: None,
11801210 },
1211+ Command {
1212+ name: "quit-all",
1213+ alias: Some("qa"),
1214+ doc: "Close all views.",
1215+ fun: quit_all,
1216+ completer: None,
1217+ },
1218+ Command {
1219+ name: "quit-all!",
1220+ alias: Some("qa!"),
1221+ doc: "Close all views forcefully (ignoring unsaved changes).",
1222+ fun: force_quit_all,
1223+ completer: None,
1224+ },
1225+
11811226 ];
11821227
11831228 pub static COMMANDS: Lazy<HashMap<&'static str, &'static Command>> = Lazy::new(|| {