1- *eval.txt* For Vim version 8.0. Last change: 2016 Sep 07
1+ *eval.txt* For Vim version 8.0. Last change: 2016 Sep 22
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -125,7 +125,8 @@ cleared. A List, Dictionary or Float is not a Number or String, thus
125125evaluates to FALSE.
126126
127127 *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* *E913*
128- List, Dictionary, Funcref and Job types are not automatically converted.
128+ List, Dictionary, Funcref, Job and Channel types are not automatically
129+ converted.
129130
130131 *E805* *E806* *E808*
131132When mixing Number and Float the Number is converted to Float. Otherwise
@@ -643,7 +644,7 @@ It's possible to form a variable name with curly braces, see
643644
644645Expression syntax summary, from least to most significant:
645646
646- | expr1 | expr2
647+ | expr1 | expr2
647648 expr2 ? expr1 : expr1 if-then-else
648649
649650| expr2 | expr3
@@ -691,7 +692,7 @@ Expression syntax summary, from least to most significant:
691692 expr8.name entry in a | Dictionary |
692693 expr8(expr1, ...) function call with | Funcref | variable
693694
694- | expr9 | number number constant
695+ | expr9 | number number constant
695696 "string" string constant, backslash is special
696697 'string' string constant, ' is doubled
697698 [expr1, ...] | List |
@@ -957,7 +958,7 @@ expr8[expr1] item of String or |List| *expr-[]* *E111*
957958 *E909* *subscript*
958959If expr8 is a Number or String this results in a String that contains the
959960expr1'th single byte from expr8. expr8 is used as a String, expr1 as a
960- Number. This doesn't recognize multi-byte encodings, see | byteidx() | for
961+ Number. This doesn't recognize multi-byte encodings, see ` byteidx ()` for
961962an alternative, or use `split ()` to turn the string into a list of characters.
962963
963964Index zero gives the first byte. This is like it works in C. Careful:
@@ -1244,7 +1245,7 @@ The arguments are optional. Example: >
12441245< error function
12451246 *closure*
12461247Lambda expressions can access outer scope variables and arguments. This is
1247- often called a closure. Example where "i" a and "a:arg" are used in a lambda
1248+ often called a closure. Example where "i" and "a:arg" are used in a lambda
12481249while they exist in the function scope. They remain valid even after the
12491250function returns: >
12501251 :function Foo(arg)
@@ -2072,8 +2073,8 @@ expand({expr} [, {nosuf} [, {list}]])
20722073feedkeys({string} [, {mode} ]) Number add key sequence to typeahead buffer
20732074filereadable({file} ) Number | TRUE | if {file} is a readable file
20742075filewritable({file} ) Number | TRUE | if {file} is a writable file
2075- filter({expr } , {string } ) List/Dict remove items from {expr } where
2076- {string } is 0
2076+ filter({expr1 } , {expr2 } ) List/Dict remove items from {expr1 } where
2077+ {expr2 } is 0
20772078finddir({name} [, {path} [, {count} ]])
20782079 String find directory {name} in {path}
20792080findfile({name} [, {path} [, {count} ]])
@@ -2097,7 +2098,7 @@ garbagecollect([{atexit}]) none free memory, breaking cyclic references
20972098get({list} , {idx} [, {def} ]) any get item {idx} from {list} or {def}
20982099get({dict} , {key} [, {def} ]) any get item {key} from {dict} or {def}
20992100get({func} , {what} ) any get property of funcref/partial {func}
2100- getbufinfo([{expr} ]) List information about buffers
2101+ getbufinfo([{expr} ]) List information about buffers
21012102getbufline({expr} , {lnum} [, {end} ])
21022103 List lines {lnum} to {end} of buffer {expr}
21032104getbufvar({expr} , {varname} [, {def} ])
@@ -2128,12 +2129,12 @@ getqflist([{what}]) List list of quickfix items
21282129getreg([{regname} [, 1 [, {list} ]]])
21292130 String or List contents of register
21302131getregtype([{regname} ]) String type of register
2131- gettabinfo([{expr} ]) List list of tab pages
2132+ gettabinfo([{expr} ]) List list of tab pages
21322133gettabvar({nr} , {varname} [, {def} ])
21332134 any variable {varname} in tab {nr} or {def}
21342135gettabwinvar({tabnr} , {winnr} , {name} [, {def} ])
21352136 any {name} in {winnr} in tab page {tabnr}
2136- getwininfo([{winid} ]) List list of windows
2137+ getwininfo([{winid} ]) List list of windows
21372138getwinposx() Number X coord in pixels of GUI Vim window
21382139getwinposy() Number Y coord in pixels of GUI Vim window
21392140getwinvar({nr} , {varname} [, {def} ])
@@ -2197,7 +2198,7 @@ localtime() Number current time
21972198log({expr} ) Float natural logarithm (base e) of {expr}
21982199log10({expr} ) Float logarithm of Float {expr} to base 10
21992200luaeval({expr} [, {expr} ]) any evaluate | Lua | expression
2200- map({expr } , {string } ) List/Dict change each item in {expr } to {expr}
2201+ map({expr1 } , {expr2 } ) List/Dict change each item in {expr1 } to {expr}
22012202maparg({name} [, {mode} [, {abbr} [, {dict} ]]])
22022203 String or Dict
22032204 rhs of mapping {name} in mode {mode}
@@ -3701,9 +3702,10 @@ filter({expr1}, {expr2}) *filter()*
37013702 is zero remove the item from the | List | or | Dictionary | .
37023703 {expr2} must be a | string | or | Funcref | .
37033704
3704- if {expr2} is a | string | , inside {expr2} | v:val | has the value
3705+ If {expr2} is a | string | , inside {expr2} | v:val | has the value
37053706 of the current item. For a | Dictionary | | v:key | has the key
3706- of the current item.
3707+ of the current item and for a | List | | v:key | has the index of
3708+ the current item.
37073709 Examples: >
37083710 call filter(mylist, 'v:val !~ "OLD"')
37093711< Removes the items where "OLD" appears. >
@@ -3725,7 +3727,11 @@ filter({expr1}, {expr2}) *filter()*
37253727 return a:idx % 2 == 1
37263728 endfunc
37273729 call filter(mylist, function('Odd'))
3728- <
3730+ < It is shorter when using a | lambda | : >
3731+ call filter(myList, {idx, val -> idx * val <= 42})
3732+ < If you do not use "val" you can leave it out: >
3733+ call filter(myList, {idx -> idx % 2 == 1})
3734+
37293735 The operation is done in-place. If you want a |List| or
37303736 |Dictionary| to remain unmodified make a copy first: >
37313737 :let l = filter(copy(mylist), 'v:val =~ "KEEP"')
@@ -5439,6 +5445,10 @@ map({expr1}, {expr2}) *map()*
54395445 return a:key . '-' . a:val
54405446 endfunc
54415447 call map(myDict, function('KeyValue'))
5448+ < It is shorter when using a | lambda | : >
5449+ call map(myDict, {key, val -> key . '-' . val})
5450+ < If you do not use "val" you can leave it out: >
5451+ call map(myDict, {key -> 'item: ' . key})
54425452<
54435453 The operation is done in-place. If you want a | List | or
54445454 | Dictionary | to remain unmodified make a copy first: >
0 commit comments