Mercurial > vim
diff runtime/doc/vim9.txt @ 24569:e3ec2ec8841a
Update runtime files
Commit: https://github.com/vim/vim/commit/4c295027a426986566cd7a76c47a6d3a529727e7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 2 17:19:11 2021 +0200
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 02 May 2021 17:30:05 +0200 |
parents | 3bfec39ce31c |
children | e69e7133c9cf |
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 Apr 11 +*vim9.txt* For Vim version 8.2. Last change: 2021 Apr 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -157,6 +157,11 @@ Compilation is done when any of these is *E1091* If compilation fails it is not tried again on the next call, instead this error is given: "E1091: Function is not compiled: {name}". +Compilation will fail when encountering a user command that has not been +created yet. In this case you can call `execute()` to invoke it at runtime. > + def MyFunc() + execute('DefinedLater') + enddef `:def` has no options like `:function` does: "range", "abort", "dict" or "closure". A `:def` function always aborts on an error (unless `:silent!` was @@ -605,6 +610,44 @@ Notes: echo [1, 2] [3, 4] + +White space ~ + +Vim9 script enforces proper use of white space. This is no longer allowed: > + var name=234 # Error! + var name= 234 # Error! + var name =234 # Error! +There must be white space before and after the "=": > + var name = 234 # OK +White space must also be put before the # that starts a comment after a +command: > + var name = 234# Error! + var name = 234 # OK + +White space is required around most operators. + +White space is required in a sublist (list slice) around the ":", except at +the start and end: > + otherlist = mylist[v : count] # v:count has a different meaning + otherlist = mylist[:] # make a copy of the List + otherlist = mylist[v :] + otherlist = mylist[: v] + +White space is not allowed: +- Between a function name and the "(": > + Func (arg) # Error! + Func + \ (arg) # Error! + Func + (arg) # Error! + Func(arg) # OK + Func( + arg) # OK + Func( + arg # OK + ) + + No curly braces expansion ~ |curly-braces-names| cannot be used. @@ -656,6 +699,17 @@ Comparators ~ The 'ignorecase' option is not used for comparators that use strings. +Abort after error ~ + +In legacy script, when an error is encountered, Vim continues to execute +following lines. This can lead to a long sequence of errors and need to type +CTRL-C to stop it. In Vim9 script execution of commands stops at the first +error. Example: > + vim9script + var x = does-not-exist + echo 'not executed' + + For loop ~ Legacy Vim script has some tricks to make a for loop over a list handle @@ -679,43 +733,6 @@ Generally, you should not change the lis first if needed. -White space ~ - -Vim9 script enforces proper use of white space. This is no longer allowed: > - var name=234 # Error! - var name= 234 # Error! - var name =234 # Error! -There must be white space before and after the "=": > - var name = 234 # OK -White space must also be put before the # that starts a comment after a -command: > - var name = 234# Error! - var name = 234 # OK - -White space is required around most operators. - -White space is required in a sublist (list slice) around the ":", except at -the start and end: > - otherlist = mylist[v : count] # v:count has a different meaning - otherlist = mylist[:] # make a copy of the List - otherlist = mylist[v :] - otherlist = mylist[: v] - -White space is not allowed: -- Between a function name and the "(": > - Func (arg) # Error! - Func - \ (arg) # Error! - Func - (arg) # Error! - Func(arg) # OK - Func( - arg) # OK - Func( - arg # OK - ) - - Conditions and expressions ~ Conditions and expressions are mostly working like they do in other languages.