What | Vim 8 | Vim 9 |
---|---|---|
first line | vim9script |
|
comment sign | " |
# |
line continuation | echo "hello " |
echo "hello " |
variable declaration | let s:MyVar=0 |
var MyVar = 0 |
variable assignment | let s:MyVar=0 |
MyVar = 0 |
const | const and final |
|
function definition | function MyFunc(Param) abort |
def MyFunc(Param: number) |
function arguments dictionary | Present as a: |
Absent. Arguments are accessed by name. |
calling function | call MyFunc(42) |
MyFunc(42) |
Default scope of variables and functions |
global | script-locals: is optional. |
On reloading script | Nothing is removed | Existing script-local variables and functions are removed. |
ranges | %s/patt/repl/g |
:%s/patt/repl/g |
Lambda syntax | let l1 = {arg -> expression} |
var l2 = (arg) => expression |
White space around operator | Does not matter | Mostly neededvar name=234 # ✗ |
Expression within variable name |
Allowedvar_{1+1} creates variable named var_2 |
Not allowed |
Literal keys in dictionary | let dict = #{key: value} |
var dict = {key: value} |
After encountering first error | Continues | Stops |
Increment and decrement operator | Absent | Present although not in an expression yet. E.g., ++myvar and --myvar |
map() function |
Item type in initial and final expression can differ." Item type changes from number to string |
The item type of expression passed into map() must not change.# Type Mismatch Error Instead use mapnew() . |