aboutsummaryrefslogtreecommitdiff
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 9c843137f6..02bb65f13e 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -930,8 +930,14 @@ void do_bang(int addr_count, exarg_T *eap, int forceit, int do_in, int do_out)
vim_free(prevcmd);
prevcmd = newcmd;
- if (bangredo) { /* put cmd in redo buffer for ! command */
- AppendToRedobuffLit(prevcmd, -1);
+ if (bangredo) { /* put cmd in redo buffer for ! command */
+ /* If % or # appears in the command, it must have been escaped.
+ * Reescape them, so that redoing them does not substitute them by the
+ * buffername. */
+ char_u *cmd = vim_strsave_escaped(prevcmd, (char_u *)"%#");
+
+ AppendToRedobuffLit(cmd, -1);
+ vim_free(cmd);
AppendToRedobuff((char_u *)"\n");
bangredo = FALSE;
}