diff --git a/src/regexp.c b/src/regexp.c
index 216bf3a18e2586046a03d5608e9ad904fbba14b2..53559455e0cfd372d295a6d14ccb64771b48d926 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -6974,6 +6974,13 @@ vim_regsub_both(source, dest, copy, magic, backslash)
 		    else if (*s == '\\' && s[1] != NUL)
 		    {
 			++s;
+			/* Change NL to CR here too, so that this works:
+			 * :s/abc\\\ndef/\="aaa\\\nbbb"/  on text:
+			 *   abc\
+			 *   def
+			 */
+			if (*s == NL)
+			    *s = CAR;
 			had_backslash = TRUE;
 		    }
 		}