Update runtime files

This commit is contained in:
Bram Moolenaar
2020-07-10 22:00:53 +02:00
parent a7eedf317a
commit 7ff78465f7
21 changed files with 690 additions and 420 deletions

View File

@ -1,4 +1,4 @@
*vim9.txt* For Vim version 8.2. Last change: 2020 Jun 24
*vim9.txt* For Vim version 8.2. Last change: 2020 Jul 10
VIM REFERENCE MANUAL by Bram Moolenaar
@ -64,16 +64,20 @@ THIS IS STILL UNDER DEVELOPMENT - ANYTHING CAN BREAK - ANYTHING CAN CHANGE
Comments starting with # ~
In Vim script comments normally start with double quote. That can also be the
start of a string, thus in many places it cannot be used. In Vim9 script a
comment can also start with #. In Vi this is a command to list text with
numbers, but you can also use `:number` for that. >
In Vim script comments start with double quote. That can also be the start of
a string, thus in many places it cannot be used. In Vim9 script a comment
normally starts with #. In Vi this is a command to list text with numbers,
but you can also use `:number` for that. >
let count = 0 # number of occurrences
To improve readability there must be a space between the command and the #
that starts a comment. Note that #{ is the start of a dictionary, therefore
it cannot start a comment.
Since Vim9 script allows for line breaks in many places, the double quoted
comment also cannot be used at the start of a line after an expression. To
avoid confusion it is best to only use # comments.
Vim9 functions ~
@ -276,10 +280,13 @@ possible just before or after the operator. For example: >
< *E1050*
To make it possible for the operator at the start of the line to be
recognized, it is required to put a colon before a range. This will adde
recognized, it is required to put a colon before a range. This will add
"start" and print: >
let result = start
+ print
Like this: >
let result = start + print
This will assign "start" and print a line: >
let result = start
:+ print
@ -291,8 +298,32 @@ arguments: >
separator = '-'
): string
Note that "enddef" cannot be used at the start of a continuation line, it ends
the current function.
Notes:
- "enddef" cannot be used at the start of a continuation line, it ends the
current function.
- No line break is allowed in the LHS of an assignment. Specifically when
unpacking a list |:let-unpack|. This is OK: >
[var1, var2] =
Func()
< This does not work: >
[var1,
var2] =
Func()
- No line break is allowed in between arguments of an `:echo`, `:execute` and
similar commands. This is OK: >
echo [1,
2] [3,
4]
< This does not work: >
echo [1, 2]
[3, 4]
- No line break is allowed in the arguments of a lambda, between the "{" and
"->". This is OK: >
filter(list, {k, v ->
v > 0})
< This does not work: >
filter(list, {k,
v -> v > 0})
No curly braces expansion ~
@ -318,7 +349,8 @@ Vim9 script enforces proper use of white space. This is no longer allowed: >
let var =234 " Error!
There must be white space before and after the "=": >
let var = 234 " OK
White space must also be put before the # that starts a comment: >
White space must also be put before the # that starts a comment after a
command: >
let var = 234# Error!
let var = 234 # OK
@ -479,6 +511,22 @@ prefix.
Note that for command line completion of {func} you
can prepend "s:" to find script-local functions.
Limitations ~
Local variables will not be visible to string evaluation. For example: >
def EvalString(): list<string>
let list = ['aa', 'bb', 'cc', 'dd']
return range(1, 2)->map('list[v:val]')
enddef
The map argument is a string expression, which is evaluated without the
function scope. Instead, use a lambda: >
def EvalString(): list<string>
let list = ['aa', 'bb', 'cc', 'dd']
return range(1, 2)->map({ _, v -> list[v] })
enddef
==============================================================================
4. Types *vim9-types*