diff --git a/src/option.c b/src/option.c
--- a/src/option.c
+++ b/src/option.c
@@ -7670,14 +7670,38 @@
 #endif
 
     /* when 'swf' is set, create swapfile, when reset remove swapfile */
-    else if ((int *)varp == &curbuf->b_p_swf)
-    {
-	if (curbuf->b_p_swf && p_uc)
-	    ml_open_file(curbuf);		/* create the swap file */
+    else if ((int *)varp == &curbuf->b_p_swf || (int *)varp == &p_swf)
+    {
+	buf_T *save_curbuf = curbuf;
+
+	if ((opt_flags & OPT_GLOBAL) || !opt_flags)
+	{
+	    /* iterate over all buffers */
+	    for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
+	    {
+		if (p_swf && p_uc)
+		{
+		    curbuf->b_p_swf = TRUE;
+		    ml_open_file(curbuf);  /* create the swap file */
+		}
+		else
+		{
+		    curbuf->b_p_swf = FALSE;
+		    mf_close_file(curbuf, TRUE); /* remove the swap file */
+		}
+	    }
+	}
 	else
-	    /* no need to reset curbuf->b_may_swap, ml_open_file() will check
-	     * buf->b_p_swf */
-	    mf_close_file(curbuf, TRUE);	/* remove the swap file */
+	{
+	    if (curbuf->b_p_swf && p_uc)
+		ml_open_file(curbuf);		/* create the swap file */
+	    else
+		/* no need to reset curbuf->b_may_swap, ml_open_file() will check
+		* buf->b_p_swf */
+		mf_close_file(curbuf, TRUE);	/* remove the swap file */
+	}
+
+	curbuf = save_curbuf;
     }
 
     /* when 'terse' is set change 'shortmess' */
