I'm trying to add a count to one of my key-map bindings. However, the following does not work as expected:
vim.keymap.set("n", "<leader>o", vim.v.count .. 'o<Esc>')
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 can one correctly use vim.v.count
with vim.keymap.set
?
If I use vim.keymap.set("n", "<leader>o", 5 .. 'o<Esc>')
it works as expected. 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.