summaryrefslogtreecommitdiff
path: root/runtime/doc/vim9.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/vim9.txt')
-rw-r--r--runtime/doc/vim9.txt17
1 files changed, 12 insertions, 5 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index 9329aa9c7..856ec2f11 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1,4 +1,4 @@
-*vim9.txt* For Vim version 8.2. Last change: 2021 Nov 22
+*vim9.txt* For Vim version 8.2. Last change: 2021 Dec 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -234,9 +234,10 @@ the "name#" prefix is sufficient. >
def scriptname#function() # autoload
When using `:function` or `:def` to specify a nested function inside a `:def`
-function, this nested function is local to the code block it is defined in.
-In a `:def` function it is not possible to define a script-local function. It
-is possible to define a global function by using the "g:" prefix.
+function and no namespace was given, this nested function is local to the code
+block it is defined in. In a `:def` function it is not possible to define a
+script-local function. It is possible to define a global function by using
+the "g:" prefix.
When referring to a function and no "s:" or "g:" prefix is used, Vim will
search for the function:
@@ -820,10 +821,16 @@ error. Example: >
For loop ~
-The loop variable must not exist yet: >
+The loop variable must not be declared yet: >
var i = 1
for i in [1, 2, 3] # Error!
+It is possible to use a global variable though: >
+ g:i = 1
+ for g:i in [1, 2, 3]
+ echo g:i
+ endfor
+
Legacy Vim script has some tricks to make a for loop over a list handle
deleting items at the current or previous item. In Vim9 script it just uses
the index, if items are deleted then items in the list will be skipped.