Hello Ingo! 2015/5/3(Sun) 4:46:50 UTC+9 Ingo Karkat: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello Vim developers, > > if you do a :substitute/foo/bar/c and then choose (a)ll as the answer, > a repeat of the substitution via g& or :&& does not confirm each > substitution any more; i.e. the :s_c flag is *not* kept! > > The documentation of g& and :s_& explicitly state that they "Keep the > flags from the previous substitute command". > > Likewise, answering (l)ast omits a given :s_g flag on repetition. > > > The problem is that the static flags do_all and do_ask are modified by > the answers, and the modified answers are then reused on repetition, > whereas the original ones should be restored in that case. From do_sub() > : > > static int do_all = FALSE; /* do multiple substitutions > per line */ > static int do_ask = FALSE; /* ask for confirmation */ > > [...] > if (typed == 'l') > { > /* last: replace and then stop */ > do_all = FALSE; > line2 = lnum; > break; > } > if (typed == 'a') > { > do_ask = FALSE; > break; > } > > Note: This was originally raised on Stack Overflow: > http://stackoverflow.com/questions/30000450/why-vim-does-not-preserve-c- > flag-when-g-used
I understand this problem. I think this should be corrected. So, I wrote a patch. Please confirm this. Thanks. Best regards, Hirohito Higashi (a.k.a h_east) -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4279,6 +4279,8 @@ static int do_list = FALSE; /* list last line with subs. */ static int do_number = FALSE; /* list last line with line nr*/ static int do_ic = 0; /* ignore case flag */ + int save_do_all; /* remember user specified 'g' flag */ + int save_do_ask; /* remember user specified 'c' flag */ char_u *pat = NULL, *sub = NULL; /* init for GCC */ int delimiter; int sublen; @@ -4514,6 +4516,9 @@ if (do_count) do_ask = FALSE; + save_do_all = do_all; + save_do_ask = do_ask; + /* * check for a trailing count */ @@ -5327,6 +5332,9 @@ #endif vim_regfree(regmatch.regprog); + + do_all = save_do_all; + do_ask = save_do_ask; } /*