Mercurial > vim
diff runtime/doc/vim9.txt @ 26438:c725b8e17f1f
Update runtime files
Commit: https://github.com/vim/vim/commit/4700398e384f38f752b432e187462f404b96847d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 5 21:54:04 2021 +0000
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 05 Dec 2021 23:00:08 +0100 |
parents | 80b555c4aed0 |
children | 3a63b1e4a6f4 |
line wrap: on
line diff
--- 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.