fix(defaults): only repeat macro for each selected line if linewise (#28289)

As mentioned in #28287, repeating a macro for each selected line doesn't
really make sense in non-linewise Visual mode.

Fix #28287
This commit is contained in:
zeertzjq
2024-04-15 03:43:33 +08:00
committed by GitHub
parent f6a3fdd684
commit aa1d0ac095
5 changed files with 15 additions and 51 deletions

View File

@@ -78,19 +78,20 @@ do
--- See |&-default|
vim.keymap.set('n', '&', ':&&<CR>', { desc = ':help &-default' })
--- Use Q in visual mode to execute a macro on each line of the selection. #21422
--- Use Q in Visual mode to execute a macro on each line of the selection. #21422
--- This only make sense in linewise Visual mode. #28287
---
--- Applies to @x and includes @@ too.
vim.keymap.set(
'x',
'Q',
':normal! @<C-R>=reg_recorded()<CR><CR>',
{ silent = true, desc = ':help v_Q-default' }
"mode() == 'V' ? ':normal! @<C-R>=reg_recorded()<CR><CR>' : 'Q'",
{ silent = true, expr = true, desc = ':help v_Q-default' }
)
vim.keymap.set(
'x',
'@',
"':normal! @'.getcharstr().'<CR>'",
"mode() == 'V' ? ':normal! @'.getcharstr().'<CR>' : '@'",
{ silent = true, expr = true, desc = ':help v_@-default' }
)