comparison 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
comparison
equal deleted inserted replaced
26437:11441fe9dc13 26438:c725b8e17f1f
1 *vim9.txt* For Vim version 8.2. Last change: 2021 Nov 22 1 *vim9.txt* For Vim version 8.2. Last change: 2021 Dec 01
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
232 def s:ThisFunction() # script-local 232 def s:ThisFunction() # script-local
233 def g:ThatFunction() # global 233 def g:ThatFunction() # global
234 def scriptname#function() # autoload 234 def scriptname#function() # autoload
235 235
236 When using `:function` or `:def` to specify a nested function inside a `:def` 236 When using `:function` or `:def` to specify a nested function inside a `:def`
237 function, this nested function is local to the code block it is defined in. 237 function and no namespace was given, this nested function is local to the code
238 In a `:def` function it is not possible to define a script-local function. It 238 block it is defined in. In a `:def` function it is not possible to define a
239 is possible to define a global function by using the "g:" prefix. 239 script-local function. It is possible to define a global function by using
240 the "g:" prefix.
240 241
241 When referring to a function and no "s:" or "g:" prefix is used, Vim will 242 When referring to a function and no "s:" or "g:" prefix is used, Vim will
242 search for the function: 243 search for the function:
243 - in the function scope, in block scopes 244 - in the function scope, in block scopes
244 - in the script scope, possibly imported 245 - in the script scope, possibly imported
818 echo 'not executed' 819 echo 'not executed'
819 820
820 821
821 For loop ~ 822 For loop ~
822 823
823 The loop variable must not exist yet: > 824 The loop variable must not be declared yet: >
824 var i = 1 825 var i = 1
825 for i in [1, 2, 3] # Error! 826 for i in [1, 2, 3] # Error!
827
828 It is possible to use a global variable though: >
829 g:i = 1
830 for g:i in [1, 2, 3]
831 echo g:i
832 endfor
826 833
827 Legacy Vim script has some tricks to make a for loop over a list handle 834 Legacy Vim script has some tricks to make a for loop over a list handle
828 deleting items at the current or previous item. In Vim9 script it just uses 835 deleting items at the current or previous item. In Vim9 script it just uses
829 the index, if items are deleted then items in the list will be skipped. 836 the index, if items are deleted then items in the list will be skipped.
830 Example legacy script: > 837 Example legacy script: >