-*cmdline.txt* For Vim version 9.1. Last change: 2024 Apr 27
+*cmdline.txt* For Vim version 9.1. Last change: 2024 Aug 15
VIM REFERENCE MANUAL by Bram Moolenaar
:keepp[atterns] {command} *:keepp* *:keeppatterns*
Execute {command}, without adding anything to the search
- history
+ history or modifying the last substitute pattern.
==============================================================================
2. Command-line completion *cmdline-completion*
-*version9.txt* For Vim version 9.1. Last change: 2024 Jul 30
+*version9.txt* For Vim version 9.1. Last change: 2024 Aug 15
VIM REFERENCE MANUAL by Bram Moolenaar
mark deprecated attributes from LSP server) |complete-items|
- the regex engines match correctly case-insensitive multi-byte characters
(and apply proper case folding)
+- |:keeppatterns| preserves the last substitute pattern when used with |:s|
*added-9.2*
Added ~
int endcolumn = FALSE; // cursor in last column when done
pos_T old_cursor = curwin->w_cursor;
int start_nsubs;
+ int keeppatterns = cmdmod.cmod_flags & CMOD_KEEPPATTERNS;
#ifdef FEAT_EVAL
int save_ma = 0;
int save_sandbox = 0;
// out of memory
return;
}
- else
+ else if (!keeppatterns)
{
vim_free(old_sub);
old_sub = vim_strsave(sub);
ex_may_print(eap);
}
- if ((cmdmod.cmod_flags & CMOD_KEEPPATTERNS) == 0)
+ if (!keeppatterns)
save_re_pat(RE_SUBST, pat, patlen, magic_isset());
// put pattern in history
add_to_history(HIST_SEARCH, pat, patlen, TRUE, NUL);
a
foobar
-substitute foo asdf
+substitute foo asdf foo
one two
.
/^substitute
s/foo/bar/
call assert_equal('foo', @/)
- call assert_equal('substitute bar asdf', getline('.'))
+ call assert_equal('substitute bar asdf foo', getline('.'))
/^substitute
keeppatterns s/asdf/xyz/
call assert_equal('^substitute', @/)
- call assert_equal('substitute bar xyz', getline('.'))
+ call assert_equal('substitute bar xyz foo', getline('.'))
+
+ /^substitute
+ &
+ call assert_equal('^substitute', @/)
+ call assert_equal('substitute bar xyz bar', getline('.'))
exe "normal /bar /e\<CR>"
call assert_equal(15, col('.'))
normal -
keeppatterns /xyz
call assert_equal('bar ', @/)
- call assert_equal('substitute bar xyz', getline('.'))
+ call assert_equal('substitute bar xyz bar', getline('.'))
exe "normal 0dn"
- call assert_equal('xyz', getline('.'))
+ call assert_equal('xyz bar', getline('.'))
close!
endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 677,
/**/
676,
/**/