Vimscript: Function parameter (scoping)

You give and define a function parameter as you'd except.

Yet in Vimscript you prefix variables with a single letter and a :. This gives them scope. (If you don't, you by default get function scoping)

When you have function parameter, this parameter has function argument scope, a:some_function_param. So you must use a:some_function_param to access it.

function Hello(the_param)
  echo a:the_param

And you'd use :call Hello('something something something')


Edit on github
comments powered by Disqus
Click me