1- *eval.txt* For Vim version 8.2. Last change: 2021 Jan 10
1+ *eval.txt* For Vim version 8.2. Last change: 2021 Jan 13
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -314,6 +314,9 @@ similar to -1. >
314314 :let shortlist = mylist[2:2] " List with one item: [3]
315315 :let otherlist = mylist[:] " make a copy of the List
316316
317+ Notice that the last index is inclusive. If you prefer using an exclusive
318+ index use the |slice()| method.
319+
317320If the first index is beyond the last item of the List or the second item is
318321before the first item, the result is an empty list. There is no error
319322message.
@@ -1217,6 +1220,9 @@ a Number it is first converted to a String.
12171220In Vim9 script the indexes are character indexes. To use byte indexes use
12181221|strpart()|.
12191222
1223+ The item at index expr1b is included, it is inclusive. For an exclusive index
1224+ use the |slice()| function.
1225+
12201226If expr1a is omitted zero is used. If expr1b is omitted the length of the
12211227string minus one is used.
12221228
@@ -2536,6 +2542,9 @@ expand({expr} [, {nosuf} [, {list}]])
25362542expandcmd({expr}) String expand {expr} like with `:edit`
25372543extend({expr1}, {expr2} [, {expr3}])
25382544 List/Dict insert items of {expr2} into {expr1}
2545+ extendnew({expr1}, {expr2} [, {expr3}])
2546+ List/Dict like |extend()| but creates a new
2547+ List or Dictionary
25392548feedkeys({string} [, {mode}]) Number add key sequence to typeahead buffer
25402549filereadable({file}) Number |TRUE| if {file} is a readable file
25412550filewritable({file}) Number |TRUE| if {file} is a writable file
@@ -2784,6 +2793,7 @@ pyxeval({expr}) any evaluate |python_x| expression
27842793rand([{expr}]) Number get pseudo-random number
27852794range({expr} [, {max} [, {stride}]])
27862795 List items from {expr} to {max}
2796+ readblob({fname}) Blob read a |Blob| from {fname}
27872797readdir({dir} [, {expr} [, {dict}]])
27882798 List file names in {dir} selected by {expr}
27892799readdirex({dir} [, {expr} [, {dict}]])
@@ -2892,6 +2902,8 @@ sign_unplacelist({list}) List unplace a list of signs
28922902simplify({filename}) String simplify filename as much as possible
28932903sin({expr}) Float sine of {expr}
28942904sinh({expr}) Float hyperbolic sine of {expr}
2905+ slice({expr}, {start} [, {end}]) String, List or Blob
2906+ slice of a String, List or Blob
28952907sort({list} [, {func} [, {dict}]])
28962908 List sort {list}, using {func} to compare
28972909sound_clear() none stop playing all sounds
@@ -3025,7 +3037,8 @@ tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
30253037trim({text} [, {mask} [, {dir}]])
30263038 String trim characters in {mask} from {text}
30273039trunc({expr}) Float truncate Float {expr}
3028- type({name}) Number type of variable {name}
3040+ type({expr}) Number type of value {expr}
3041+ typename({expr}) String representation of the type of {expr}
30293042undofile({name}) String undo file name for {name}
30303043undotree() List undo file tree
30313044uniq({list} [, {func} [, {dict}]])
@@ -4532,6 +4545,13 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
45324545 mylist->extend(otherlist)
45334546
45344547
4548+ extendnew({expr1}, {expr2} [, {expr3}]) *extendnew()*
4549+ Like |extend()| but instead of adding items to {expr1} a new
4550+ List or Dictionary is created and returned. {expr1} remains
4551+ unchanged. Items can still be changed by {expr2}, if you
4552+ don't want that use |deepcopy()| first.
4553+
4554+
45354555feedkeys({string} [, {mode}]) *feedkeys()*
45364556 Characters in {string} are queued for processing as if they
45374557 come from a mapping or were typed by the user.
@@ -8266,6 +8286,14 @@ rand([{expr}]) *rand()* *random*
82668286 :echo rand(seed)
82678287 :echo rand(seed) % 16 " random number 0 - 15
82688288<
8289+
8290+ readblob({fname}) *readblob()*
8291+ Read file {fname} in binary mode and return a |Blob|.
8292+ When the file can't be opened an error message is given and
8293+ the result is an empty |Blob|.
8294+ Also see |readfile()| and |writefile()|.
8295+
8296+
82698297readdir({directory} [, {expr} [, {dict}]]) *readdir()*
82708298 Return a list with file and directory names in {directory}.
82718299 You can also use |glob()| if you don't need to do complicated
@@ -8380,6 +8408,7 @@ readdirex({directory} [, {expr} [, {dict}]]) *readdirex()*
83808408 Can also be used as a |method|: >
83818409 GetDirName()->readdirex()
83828410<
8411+
83838412 *readfile()*
83848413readfile({fname} [, {type} [, {max}]])
83858414 Read file {fname} and return a |List|, each line of the file
@@ -8391,8 +8420,6 @@ readfile({fname} [, {type} [, {max}]])
83918420 - When the last line ends in a NL an extra empty list item is
83928421 added.
83938422 - No CR characters are removed.
8394- When {type} contains "B" a |Blob| is returned with the binary
8395- data of the file unmodified.
83968423 Otherwise:
83978424 - CR characters that appear before a NL are removed.
83988425 - Whether the last line ends in a NL or not does not matter.
@@ -8410,6 +8437,9 @@ readfile({fname} [, {type} [, {max}]])
84108437 Note that without {max} the whole file is read into memory.
84118438 Also note that there is no recognition of encoding. Read a
84128439 file into a buffer if you need to.
8440+ Deprecated (use |readblob()| instead): When {type} contains
8441+ "B" a |Blob| is returned with the binary data of the file
8442+ unmodified.
84138443 When the file can't be opened an error message is given and
84148444 the result is an empty list.
84158445 Also see |writefile()|.
@@ -9852,6 +9882,18 @@ sinh({expr}) *sinh()*
98529882 {only available when compiled with the |+float| feature}
98539883
98549884
9885+ slice({expr}, {start} [, {end}]) *slice()*
9886+ Similar to using a |slice| "expr[start : end]", but "end" is
9887+ used exclusive. And for a string the indexes are used as
9888+ character indexes instead of byte indexes, like in
9889+ |vim9script|.
9890+ When {end} is omitted the slice continues to the last item.
9891+ When {end} is -1 the last item is omitted.
9892+
9893+ Can also be used as a |method|: >
9894+ GetList()->slice(offset)
9895+
9896+
98559897sort({list} [, {func} [, {dict}]]) *sort()* *E702*
98569898 Sort the items in {list} in-place. Returns {list}.
98579899
@@ -11131,6 +11173,14 @@ type({expr}) The result is a Number representing the type of {expr}.
1113111173< Can also be used as a |method|: >
1113211174 mylist->type()
1113311175
11176+
11177+ typename({expr}) *typename()*
11178+ Return a string representation of the type of {expr}.
11179+ Example: >
11180+ echo typename([1, 2, 3])
11181+ list<number>
11182+
11183+
1113411184undofile({name}) *undofile()*
1113511185 Return the name of the undo file that would be used for a file
1113611186 with name {name} when writing. This uses the 'undodir'
@@ -11288,9 +11338,11 @@ win_execute({id}, {command} [, {silent}]) *win_execute()*
1128811338 call win_execute(winid, 'set syntax=python')
1128911339< Doing the same with `setwinvar()` would not trigger
1129011340 autocommands and not actually show syntax highlighting.
11341+
1129111342 *E994*
1129211343 Not all commands are allowed in popup windows.
11293- When window {id} does not exist then no error is given.
11344+ When window {id} does not exist then no error is given and
11345+ an empty string is returned.
1129411346
1129511347 Can also be used as a |method|, the base is passed as the
1129611348 second argument: >
0 commit comments