Variable
List unpacking
:h let-unpack
Vim allows you to create and populate two variables from a list:
let [var1, var2] = mylist
which is equivalent to:
let var1 = mylist[0] let var2 = mylist[1]
There is also an (untagged) section on that help page titled "List unpack". It says you can do:
let [var1, var2; rest] = mylist
to collect an optional unknown number of items in a list.
And you can use a related trick to perform operations on multiple existing variables at once:
let [var1, var2] += 1
There is lots to like about this language.
Condition
-
"foo": False -
1: True -
0: False -
"1foo": True
==# case sensitive
==? case insensitive
Strings
-
"3foo" + "5bar" = 8 -
10 + "20.10" = 30"20.10" convert to number is 20.
Function
Arguments
function Varg(...) echom a:0 echom a:1 echo a:000 endfunction
- a:0 : the length of variable-length
- a:1 : the 1st arg
- a:000 : the list of all args