Question reposted on StackOverflow, where it's receiving more attention.
Given the following function in the .vimrc
file,
fu! MyFun(count)
echo a:count
echo a:count
if a:count > 0
normal ,
call MyFun(a:count - 1)
endif
endf
calling :call MyFun(3)
generates the following output.
3
3
2
2
1
1
0
0
However, if I define the mapping nn , :<C-U>execute "call MyFun(" . v:count . ")"<CR>
, then the call to :call MyFun(3)
generates
3
0
2
0
1
0
0
0
I do understand that the mapping of ,
makes the MyFun
function call itself twice (if a:count > 0
), however I cannot understand how this can cause a different result of the two successive calls to echo a:count
.
normal ,
call the function with a count 0 when you do the map version? Id expect to see 33002200110000 – D. Ben Knoble♦ Sep 26 '19 at 2:18