I'm trying to create a function mapping that takes a count, in this case the number of lines to yank to the system clipboard.
func! Clipboard() echo 'Clipboard function called' if v:count is 0 normal "+yy else exec 'normal ' . v:count . '"+yy' endif endfunc nmap YY :call Clipboard()<CR>
Problem is it's being called multiple times when a count is provided and even then the clipboard ends up with only one entry. Pretty bizarre.
e.g. with this text
first line second line third line fourth line fifth line sixth line seventh line eighth line
I place the cursor at 'first line' and hit '4YY' and the clipboard ends up with these lines:
fourth line fifth line sixth line seventh line
How's this happening?
The messages printed are:
4 lines yanked 4 lines yanked 4 lines yanked 4 lines yanked
If the function is really being called 4 times like the message says, why do I have only one entry in the clipboard?