diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index b79a259..e9c11df 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4745,6 +4745,12 @@ do_sub(eap)
 			    getvcol(curwin, &curwin->w_cursor, &sc, NULL, NULL);
 			    curwin->w_cursor.col = regmatch.endpos[0].col - 1;
 			    getvcol(curwin, &curwin->w_cursor, NULL, NULL, &ec);
+			    if (curwin->w_p_nu)
+			    {
+				int numw = number_width(curwin) + 1;
+				sc += numw;
+				ec += numw;
+			    }
 			    msg_start();
 			    for (i = 0; i < (long)sc; ++i)
 				msg_putchar(' ');
