diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-15 03:43:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-15 03:43:33 +0800 |
commit | aa1d0ac095dcc08b6069d716222739e83cbe051f (patch) | |
tree | 03b80415d539a8b601505a4bd8426bcd596b332b /runtime/lua/vim/_defaults.lua | |
parent | f6a3fdd6848d67dc54cebb6c297f8ebdc109c3a3 (diff) | |
download | rneovim-aa1d0ac095dcc08b6069d716222739e83cbe051f.tar.gz rneovim-aa1d0ac095dcc08b6069d716222739e83cbe051f.tar.bz2 rneovim-aa1d0ac095dcc08b6069d716222739e83cbe051f.zip |
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
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
-rw-r--r-- | runtime/lua/vim/_defaults.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 2afcc185e5..533ebbc7c3 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -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' } ) |