Since a string is considered to be a single line, a multi-line pattern
(containing \n, backslash-n) will not match. However, a literal NL character
can be matched like an ordinary character. Examples:
"foo\nbar" =~ "\n" evaluates to 1
"foo\nbar" =~ "\\n" evaluates to 0
------------------------------------------------------------------------------
expr5 and expr6 *expr5* *expr6*
expr6 + expr6 Number addition, |List| or |Blob| concatenation *expr-+*
expr6 - expr6 Number subtraction *expr--*
expr6 . expr6 String concatenation *expr-.*
expr6 .. expr6 String concatenation *expr-..*
For |Lists| only "+" is possible and then both expr6 must be a list. The
result is a new list with the two lists Concatenated.
For String concatenation ".." is preferred, since "." is ambiguous, it is also
used for |Dict| member access and floating point numbers.
expr7 * expr7 Number multiplication *expr-star*
expr7 / expr7 Number division *expr-/*
expr7 % expr7 Number modulo *expr-%*
For all, except "." and "..", Strings are converted to Numbers.
For bitwise operators see |and()|, |or()| and |xor()|.
Note the difference between "+" and ".":
"123" + "456" = 579
"123" . "456" = "123456"
Since '.' has the same precedence as '+' and '-', you need to read: >
1 . 90 + 90.0
As: >
(1 . 90) + 90.0
That works, since the String "190" is automatically converted to the Number
190, which can be added to the Float 90.0. However: >
1 . 90 * 90.0
Should be read as: >
1 . (90 * 90.0)
Since '.' has lower precedence than "*". This does NOT work, since this
attempts to concatenate a Float and a String.
When dividing a Number by zero the result depends on the value:
0 / 0 = -0x80000000 (like NaN for Float)
>0 / 0 = 0x7fffffff (like positive infinity)
<0 / 0 = -0x7fffffff (like negative infinity)
(before Vim 7.2 it was always 0x7fffffff)
When 64-bit Number support is enabled:
0 / 0 = -0x8000000000000000 (like NaN for Float)
>0 / 0 = 0x7fffffffffffffff (like positive infinity)
<0 / 0 = -0x7fffffffffffffff (like negative infinity)
When the righthand side of '%' is zero, the result is 0.
None of these work for |Funcref|s.
. and % do not work for Float. *E804*
------------------------------------------------------------------------------
expr7 *expr7*
! expr7 logical NOT *expr-!*
- expr7 unary minus *expr-unary--*
+ expr7 unary plus *expr-unary-+*
For '!' |TRUE| becomes |FALSE|, |FALSE| becomes |TRUE| (one).
For '-' the sign of the number is changed.
For '+' the number is unchanged. Note: "++" has no effect.
A String will be converted to a Number first.
These three can be repeated and mixed. Examples:
!-1 == 0
!!8 == 1
--9 == 9
------------------------------------------------------------------------------
expr8 *expr8*
This expression is either |expr9| or a sequence of the alternatives below,
in any order. E.g., these are all possible:
expr8[expr1].name
expr8.name[expr1]
expr8(expr1, ...)[expr1].name
expr8->(expr1, ...)[expr1]
Evaluation is always from left to right.
expr8[expr1] item of String or |List| *expr-[]* *E111*
*subscript*
In legacy Vim script:
If expr8 is a Number or String this results in a String that contains the
expr1'th single byte from expr8. expr8 is used as a String (a number is
automatically converted to a String), expr1 as a Number. This doesn't
recognize multibyte encodings, see `byteidx()` for an alternative, or use
`split()` to turn the string into a list of characters. Example, to get the
byte under the cursor: >
:let c = getline(".")[col(".") - 1]
Index zero gives the first byte. This is like it works in C. Careful:
text column numbers start with one! Example, to get the byte under the
cursor: >
:let c = getline(".")[col(".") - 1]
Index zero gives the first byte. Careful: text column numbers start with one!
If the length of the String is less than the index, the result is an empty
String. A negative