updated for version 7.4.232
Problem: ":%s/\n//" uses a lot of memory. (Aidan Marlin)
Solution: Turn this into a join command. (Christian Brabandt)
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index f99f883..5321955 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -4420,6 +4420,31 @@
endcolumn = (curwin->w_curswant == MAXCOL);
}
+ /* Recognize ":%s/\n//" and turn it into a join command, which is much
+ * more efficient.
+ * TODO: find a generic solution to make line-joining operations more
+ * efficient, avoid allocating a string that grows in size.
+ */
+ if (STRCMP(pat, "\\n") == 0 && STRLEN(pat) == 2
+ && *sub == NUL
+ && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
+ || *cmd == 'p' || *cmd == '#'))))
+ {
+ curwin->w_cursor.lnum = eap->line1;
+ if (*cmd == 'l')
+ eap->flags = EXFLAG_LIST;
+ else if (*cmd == '#')
+ eap->flags = EXFLAG_NR;
+ else if (*cmd == 'p')
+ eap->flags = EXFLAG_PRINT;
+
+ (void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE);
+ sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
+ (void)do_sub_msg(FALSE);
+ ex_may_print(eap);
+ return;
+ }
+
/*
* Find trailing options. When '&' is used, keep old options.
*/