Vimscript: Global variable

You prefix the name of your variable with g:.

You set it, from within a function for example, with let g:var_name = "something"

let g:global_var

function Hello
  let g:global_var = "Hello"

Yes, you use let from within the function.

You can see the value of g:global_var by issuing: :echo g:global_var.


Edit on github
comments powered by Disqus
Click me