I want to write a command to do the following:
- Make a visual selection.
- Call a command on the visual selection.
By way of example, I'd like to call vat
to visually select around the current tag, and then use Limelight to highlight it.
Attempt #1:
vim.api.nvim_create_user_command('HighlightTagBlock',
function()
vim.cmd.normal("vat")
vim.cmd("'<,'>Limelight")
end,
{ nargs = 0 }
)
Attempt #2:
vim.api.nvim_create_user_command('HighlightTagBlock',
function()
vim.cmd.normal("vat")
vim.cmd.visual("Limelight")
end,
{ nargs = 0 }
)
Neither of these works as expected. What's the right way to do this?