diff --git a/keymap/vim.js b/keymap/vim.js
index 4484f7a8ea928761027da2758ed84fd3388f69aa..54f2827248400e639b6e4746f92432347ddae69d 100644
--- a/keymap/vim.js
+++ b/keymap/vim.js
@@ -4515,8 +4515,8 @@
         if (CodeMirror.commands.save) {
           // If a save command is defined, call it.
           CodeMirror.commands.save(cm);
-        } else {
-          // Saves to text area if no save command is defined.
+        } else if (cm.save) {
+          // Saves to text area if no save command is defined and cm.save() is available.
           cm.save();
         }
       },