Vimscript: Closures

You have to explicitly declare your function a closure by adding closure after the function arguments.

function Hi()
  let a = "hi"
  function s:inside() closure
    echo a
  call s:inside()

Without closure, :call Hi() will print out an error.

We use s:inside to make the function script local, rather than global.


Edit on github
comments powered by Disqus
Click me