mylist[:] " shallow copy of a List
If expr8 is a |Blob| this results in a new |Blob| with the bytes in the
indexes expr1a and expr1b, inclusive. Examples: >
:let b = 0zDEADBEEF
:let bs = b[1:2] " 0zADBE
:let bs = b[] " copy of 0zDEADBEEF
Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an
error.
Watch out for confusion between a namespace and a variable followed by a colon
for a sublist: >
mylist[n:] " uses variable n
mylist[s:] " uses namespace s:, error!
expr8.name entry in a |Dictionary| *expr-entry*
If expr8 is a |Dictionary| and it is followed by a dot, then the following
name will be used as a key in the |Dictionary|. This is just like:
expr8[name].
The name must consist of alphanumeric characters, just like a variable name,
but it may start with a number. Curly braces cannot be used.
There must not be white space before or after the dot.
Examples: >
:let dict = {"one": 1, 2: "two"}
:echo dict.one " shows "1"
:echo dict.2 " shows "two"
:echo dict .2 " error because of space before the dot
Note that the dot is also used for String concatenation. To avoid confusion
always put spaces around the dot for String concatenation.
expr8(expr1, ...) |Funcref| function call *E1085*
When expr8 is a |Funcref| type variable, invoke the function it refers to.
expr8->name([args]) method call *method* *->*
expr8->{lambda}([args])
*E260* *E276*
For methods that are also available as global functions this is the same as: >
name(expr8 [, args])
There can also be methods specifically for the type of "expr8".
This allows for chaining, passing the value that one method returns to the
next method: >
mylist->filter(filterexpr)->map(mapexpr)->sort()->join()
<
Example of using a lambda: >
GetPercentage()->{x -> x * 100}()->printf('%d%%')
<
When using -> the |expr7| operators will be applied first, thus: >
-1.234->string()
Is equivalent to: >
(-1.234)->string()
And NOT: >
-(1.234->string())
<
*E274*
"->name(" must not contain white space. There can be white space before the
"->" and after the "(", thus you can split the lines like this: >
mylist
\ ->filter(filterexpr)
\ ->map(mapexpr)
\ ->sort()
\ ->join()
When using the lambda form there must be no white space between the } and the
(.
*expr9*
------------------------------------------------------------------------------
number
number number constant *expr-number*
*0x* *hex-number* *0o* *octal-number* *binary-number*
Decimal, Hexadecimal (starting with 0x or 0X), Binary (starting with 0b or 0B)
and Octal (starting with 0, 0o or 0O).
*floating-point-format*
Floating point numbers can be written in two forms:
[-+]{N}.{M}
[-+]{N}.{M}[eE][-+]{exp}
{N} and {M} are numbers. Both {N} and {M} must be present and can only
contain digits.
[-+] means there is an optional plus or minus sign.
{exp} is the exponent, power of 10.
Only a decimal point is accepted, not a comma. No matter what the current
locale is.
Examples:
123.456
+0.0001
55.0
-0.123
1.234e03
1.0E-6
-3.1416e+88
These are INVALID:
3. empty {M}
1e40 missing .{M}
Rationale:
Before floating point was introduced, the text "123.456" was interpreted as
the two numbers "123" and "456", both converted to a string and concatenated,
resulting in the string "123456". Since this was considered pointless, and we
could not find it intentionally being used in Vim scripts, this backwards
incompatibility was accepted in favor of being able to use the normal notation
for floating point numbers.
*float-pi* *float-e*
A few useful values to copy&paste: >
:let pi = 3.14159265359
:let e = 2.71828182846
Or, if you don't want to write them in as floating-point literals, you can
also use functions, like the following: >
:let pi = acos(-1.0)
:let e = exp(1.0)
<
*floating-point-precision*
The precision and range of floating points numbers depends on what "double"
means in the library Vim was compiled with. There