I'm trying to add a count to one of my keymap bindings.
vim.keymap.set("n", "<leader>o", vim.v.count .. 'o<Esc>')
does not work as expected.
My intention for this keymap is to insert count
empty lines and stay in normal mode.
If I use the key combination <leader>5o
only one new line is added and the editor is in insert mode. Only after I hit the Esc key myself 4 extra lines appear and the editor switches to normal mode.
How to correctly use vim.v.count
with vim.keymap.set
?
Also, when using this keymap, should I press 5<leader>o
or <leader>5o
?
If I use vim.keymap.set("n", "<leader>o", 5 .. 'o<Esc>')
it works as expected. After pressing <leader>o
five new lines are added and the editor stays in normal mode.
I've also tried to wrap the commands into a function vim.keymap.set("n", "<leader>o", function() ... end)
but it didn't change the behavior.