--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1528,6 +1528,16 @@
 }
 #endif
 
+// Mode for opening a script to source.  On VMS a script may be a file of
+// variable-length records (what CREATE, EDIT and FTP in ASCII mode make); the C
+// run-time returns those records without line ends in binary mode ("rb"), and
+// the whole script would become one line.  Text mode adds the line ends.
+#ifdef VMS
+# define SOURCE_FOPEN_MODE "r"
+#else
+# define SOURCE_FOPEN_MODE READBIN
+#endif
+
 #if (defined(MSWIN) && defined(FEAT_CSCOPE)) || defined(HAVE_FD_CLOEXEC)
 # define USE_FOPEN_NOINH
 /*
@@ -1723,7 +1733,7 @@
 #ifdef USE_FOPEN_NOINH
 	cookie.fp = fopen_noinh_readbin((char *)fname_exp);
 #else
-	cookie.fp = mch_fopen((char *)fname_exp, READBIN);
+	cookie.fp = mch_fopen((char *)fname_exp, SOURCE_FOPEN_MODE);
 #endif
     }
     if (cookie.fp == NULL && check_other)
@@ -1743,7 +1753,7 @@
 #ifdef USE_FOPEN_NOINH
 	    cookie.fp = fopen_noinh_readbin((char *)fname_exp);
 #else
-	    cookie.fp = mch_fopen((char *)fname_exp, READBIN);
+	    cookie.fp = mch_fopen((char *)fname_exp, SOURCE_FOPEN_MODE);
 #endif
 	}
     }
