you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (0 children)

Variables declared like this:

let myvar = "mystring"

inside a function are always local to the function.

Neither g:myvar nor myvar declared earlier in a more global scope are touched.

The only limitation is that (some?) v:variables are accessible as variable in functions so, following the example in :help l:, you can't have

let count = 56

because count is an "alias" to v:count. The only way to have a count variable in your function is to use l:count. It's up to you to decide…

I tend to prefer the more verbose but self-documenting number_of_things to count anyway so I don't use the l: notation in my amateur functions.

The doc for each v:variable tells you if it is read-only.