5

I'm learning some Vimscript code from here .

And the next lines will not compile:

function! Mapped(fn ,l)
     let new_list = deepcopy(a:l)
     call map(new_list, string(a:fn) . '(v:val)')
     return new_list
endfunction

When I'm running :source %

I'm getting the following error:

Invalid argument: Mapped(fn, l)

I cant' seem to figure out how.

8
  • Did you tried calling the function in command line?
    – SibiCoder
    Commented Jun 25, 2016 at 17:22
  • Yes I'm trying to call this function from command mode and it is resulting in "Unknown function "
    – Shikloshi
    Commented Jun 25, 2016 at 17:25
  • 1
    You should remove the space between the argument fn and the comma: function! Mapped(fn, l). Commented Jun 25, 2016 at 17:28
  • 7
    The space before comma is not accepted. This looks like a bug in the parser, report it to vim_dev. Commented Jun 25, 2016 at 18:05
  • 2
    @SatoKatsura It's a known problem and mentioned in the help (:h todo (search for function, I even posted a patch about it, but Bram didn't want to included it, since he didn't like the style Commented Jun 26, 2016 at 19:38

1 Answer 1

2

Because of a bug in vim_dev parser, the space before coma is not accepted.

Thus you must use:

function! Mapped(fn,l)
     let new_list = deepcopy(a:l)
     call map(new_list, string(a:fn) . '(v:val)')
     return new_list
endfunction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.