I suspect you are misinterpreting your results and that your function is working correctly. Check what
:echo '#'.abcd().'#'
produces. You should observe # #
and not ##
.
If not, are you sure there is only two paths in your function?
What about the else
path? You can debug it with: :debug echo abcd()
. From there you can go to n
ext instruction, or s
tep-in a function call, or f
inish the call to the current function, you can c
ontinue till next breakpoint, etc. See :h :debug
.
What is sure is that spaces can be returned in VimL. If the first line of your function is a return ' '
, you'll see that a space is returned.