# HG changeset patch # User Christian Brabandt # Date 1691792103 -7200 # Node ID a5a2a5e56c630e4787cd81a4633e680974b7521c # Parent 581a2bf3f4d670e94eddb87c701a3010e9923b39 patch 9.0.1693: Ctrl-Q not handled like Ctrl-V in replace mode Commit: https://github.com/vim/vim/commit/2d63e4b3ccc0bb34db21a3c1d024cb114f8c4071 Author: Christian Brabandt Date: Sat Aug 12 00:03:57 2023 +0200 patch 9.0.1693: Ctrl-Q not handled like Ctrl-V in replace mode Problem: Ctrl-Q not handled like Ctrl-V in replace mode Solution: Handle Ctrl-Q like Ctrl-V closes: #12686 closes: #12684 Signed-off-by: Christian Brabandt diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -4767,7 +4767,7 @@ nv_replace(cmdarg_T *cap) #endif // get another character - if (cap->nchar == Ctrl_V) + if (cap->nchar == Ctrl_V || cap->nchar == Ctrl_Q) { had_ctrl_v = Ctrl_V; cap->nchar = get_literal(FALSE); @@ -5051,7 +5051,8 @@ nv_vreplace(cmdarg_T *cap) emsg(_(e_cannot_make_changes_modifiable_is_off)); else { - if (cap->extra_char == Ctrl_V) // get another character + if (cap->extra_char == Ctrl_V || cap->extra_char == Ctrl_Q) + // get another character cap->extra_char = get_literal(FALSE); if (cap->extra_char < ' ') // Prefix a control character with CTRL-V to avoid it being used as diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -3998,4 +3998,42 @@ func Test_normal_j_below_botline() call StopVimInTerminal(buf) endfunc +" Test for r (replace) command with CTRL_V and CTRL_Q +func Test_normal_r_ctrl_v_cmd() + new + call append(0, 'This is a simple test: abcd') + exe "norm! 1gg$r\\" + call assert_equal(['This is a simple test: abc', ''], getline(1,'$')) + exe "norm! 1gg$hr\\" + call assert_equal(['This is a simple test: ab', ''], getline(1,'$')) + exe "norm! 1gg$2hr\x7e" + call assert_equal(['This is a simple test: a~', ''], getline(1,'$')) + exe "norm! 1gg$3hr\x7e" + call assert_equal(['This is a simple test: ~~', ''], getline(1,'$')) + + if &encoding == 'utf-8' + exe "norm! 1gg$4hr\u20ac" + call assert_equal(['This is a simple test:€~~', ''], getline(1,'$')) + exe "norm! 1gg$5hr\u20ac" + call assert_equal(['This is a simple test€€~~', ''], getline(1,'$')) + exe "norm! 1gg0R\xff WAS \" + call assert_equal(['ÿ WAS a simple test€€~~', ''], getline(1,'$')) + exe "norm! 1gg0elR\xffNOT\" + call assert_equal(['ÿ WASÿNOT simple test€€~~', ''], getline(1,'$')) + endif + + call setline(1, 'This is a simple test: abcd') + exe "norm! 1gg$gr\\" + call assert_equal(['This is a simple test: abc', ''], getline(1,'$')) + exe "norm! 1gg$hgr\\" + call assert_equal(['This is a simple test: ab ', ''], getline(1,'$')) + exe "norm! 1gg$2hgr\x7e" + call assert_equal(['This is a simple test: a~ ', ''], getline(1,'$')) + exe "norm! 1gg$3hgr\x7e" + call assert_equal(['This is a simple test: ~~ ', ''], getline(1,'$')) + + " clean up + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1693, +/**/ 1692, /**/ 1691,