comparison runtime/doc/vim9.txt @ 30324:0827d3d6d8c0

Update runtime files Commit: https://github.com/vim/vim/commit/9712ff1288f942736ed76c0dec014909f067eec9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 18 13:04:22 2022 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sun, 18 Sep 2022 14:15:05 +0200
parents fee9eccee266
children 1e91e26ceebf
comparison
equal deleted inserted replaced
30323:7637e274f2a6 30324:0827d3d6d8c0
1 *vim9.txt* For Vim version 9.0. Last change: 2022 Sep 10 1 *vim9.txt* For Vim version 9.0. Last change: 2022 Sep 15
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
105 `:open` 105 `:open`
106 `:s` with only flags 106 `:s` with only flags
107 `:t` 107 `:t`
108 `:xit` 108 `:xit`
109 - Some commands, especially those used for flow control, cannot be shortened. 109 - Some commands, especially those used for flow control, cannot be shortened.
110 E.g., `:throw` cannot be written as `:th`. 110 E.g., `:throw` cannot be written as `:th`. *vim9-no-shorten*
111 - You cannot use curly-braces names. 111 - You cannot use curly-braces names.
112 - A range before a command must be prefixed with a colon: > 112 - A range before a command must be prefixed with a colon: >
113 :%s/this/that 113 :%s/this/that
114 - Executing a register with "@r" does not work, you can prepend a colon or use 114 - Executing a register with "@r" does not work, you can prepend a colon or use
115 `:exe`: > 115 `:exe`: >
1334 timer_start(500 * n, (_) => { 1334 timer_start(500 * n, (_) => {
1335 echowin n 1335 echowin n
1336 }) 1336 })
1337 endfor 1337 endfor
1338 1338
1339 You need to create a closure to store the current value of "n", so that it is 1339 You need to use a block and define a variable there, and use that one in the
1340 evaluated at the time the closure is created: > 1340 closure: >
1341 def GetClosure(nr: number): func
1342 return (_) => {
1343 echowindow nr
1344 }
1345 enddef
1346
1347 for n in range(4) 1341 for n in range(4)
1348 timer_start(500 * n, GetClosure(n)) 1342 {
1343 var nr = n
1344 timer_start(500 * n, (_) => {
1345 echowin nr
1346 })
1347 }
1349 endfor 1348 endfor
1350 1349
1351 Using `echowindow` is useful in a timer, the messages go into a popup and will 1350 Using `echowindow` is useful in a timer, the messages go into a popup and will
1352 not interfere with what the user is doing when it triggers. 1351 not interfere with what the user is doing when it triggers.
1353 1352
1682 variables in legacy Vim script, but the "s:" is omitted. And they cannot be 1681 variables in legacy Vim script, but the "s:" is omitted. And they cannot be
1683 deleted. 1682 deleted.
1684 1683
1685 In Vim9 script the global "g:" namespace can still be used as before. And the 1684 In Vim9 script the global "g:" namespace can still be used as before. And the
1686 "w:", "b:" and "t:" namespaces. These have in common that variables are not 1685 "w:", "b:" and "t:" namespaces. These have in common that variables are not
1687 declared and they can be deleted. 1686 declared, have no specific type and they can be deleted. *E1304*
1688 1687
1689 A side effect of `:vim9script` is that the 'cpoptions' option is set to the 1688 A side effect of `:vim9script` is that the 'cpoptions' option is set to the
1690 Vim default value, like with: > 1689 Vim default value, like with: >
1691 :set cpo&vim 1690 :set cpo&vim
1692 One of the effects is that |line-continuation| is always enabled. 1691 One of the effects is that |line-continuation| is always enabled.
1823 1822
1824 And using the "as name" form: > 1823 And using the "as name" form: >
1825 import "otherfile.vim9script" as that 1824 import "otherfile.vim9script" as that
1826 call s:that.OtherFunc() 1825 call s:that.OtherFunc()
1827 1826
1828 However, the namespace cannot be resolved on it's own: > 1827 However, the namespace cannot be resolved on its own: >
1829 import "that.vim" 1828 import "that.vim"
1830 echo s:that 1829 echo s:that
1831 " ERROR: E1060: Expected dot after name: s:that 1830 " ERROR: E1060: Expected dot after name: s:that
1832 < 1831 <
1833 This also affects the use of |<SID>| in the legacy mapping context. Since 1832 This also affects the use of |<SID>| in the legacy mapping context. Since