comparison runtime/doc/eval.txt @ 15454:1d2b5c016f17 v8.1.0735

patch 8.1.0735: cannot handle binary data commit https://github.com/vim/vim/commit/6e5ea8d2a995b32bbc5972edc4f827b959f2702f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 12 22:47:31 2019 +0100 patch 8.1.0735: cannot handle binary data Problem: Cannot handle binary data. Solution: Add the Blob type. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/3638)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Jan 2019 23:00:06 +0100
parents 8ac454818352
children f01eb1aed348
comparison
equal deleted inserted replaced
15453:cdee6e827112 15454:1d2b5c016f17
70 70
71 Job Used for a job, see |job_start()|. *Job* *Jobs* 71 Job Used for a job, see |job_start()|. *Job* *Jobs*
72 72
73 Channel Used for a channel, see |ch_open()|. *Channel* *Channels* 73 Channel Used for a channel, see |ch_open()|. *Channel* *Channels*
74 74
75 Blob Binary Large Object. Stores any sequence of bytes. *Blob*
76 Example: 0zFF00ED015DAF
77 0z is an empty Blob.
78
75 The Number and String types are converted automatically, depending on how they 79 The Number and String types are converted automatically, depending on how they
76 are used. 80 are used.
77 81
78 Conversion from a Number to a String is by making the ASCII representation of 82 Conversion from a Number to a String is by making the ASCII representation of
79 the Number. Examples: 83 the Number. Examples:
122 non-empty String, then the value is considered to be TRUE. 126 non-empty String, then the value is considered to be TRUE.
123 Note that " " and "0" are also non-empty strings, thus considered to be TRUE. 127 Note that " " and "0" are also non-empty strings, thus considered to be TRUE.
124 A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE. 128 A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE.
125 129
126 *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* *E913* 130 *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* *E913*
127 List, Dictionary, Funcref, Job and Channel types are not automatically 131 *E974* *E975* *E976*
132 List, Dictionary, Funcref, Job, Channel and Blob types are not automatically
128 converted. 133 converted.
129 134
130 *E805* *E806* *E808* 135 *E805* *E806* *E808*
131 When mixing Number and Float the Number is converted to Float. Otherwise 136 When mixing Number and Float the Number is converted to Float. Otherwise
132 there is no automatic conversion of Float. You can use str2float() for String 137 there is no automatic conversion of Float. You can use str2float() for String
1014 the indexes expr1a and expr1b. This works like with a String, as explained 1019 the indexes expr1a and expr1b. This works like with a String, as explained
1015 just above. Also see |sublist| below. Examples: > 1020 just above. Also see |sublist| below. Examples: >
1016 :let l = mylist[:3] " first four items 1021 :let l = mylist[:3] " first four items
1017 :let l = mylist[4:4] " List with one item 1022 :let l = mylist[4:4] " List with one item
1018 :let l = mylist[:] " shallow copy of a List 1023 :let l = mylist[:] " shallow copy of a List
1024
1025 If expr8 is a |Blob| this results in a new |Blob| with the bytes in the
1026 indexes expr1a and expr1b, inclusive. Examples: >
1027 :let b = 0zDEADBEEF
1028 :let bs = b[1:2] " 0zADBE
1029 :let bs = b[] " copy ov 0zDEADBEEF
1019 1030
1020 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an 1031 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an
1021 error. 1032 error.
1022 1033
1023 Watch out for confusion between a namespace and a variable followed by a colon 1034 Watch out for confusion between a namespace and a variable followed by a colon
1154 of 'encoding'. 1165 of 'encoding'.
1155 1166
1156 Note that "\000" and "\x00" force the end of the string. 1167 Note that "\000" and "\x00" force the end of the string.
1157 1168
1158 1169
1170 blob-literal *blob-literal* *E973* *E977* *E978*
1171 ------------
1172
1173 Hexadecimal starting with 0z or 0Z, with an arbitrary number of bytes.
1174 The sequence must be an even number of hex characters. Example: >
1175 :let b = 0zFF00ED015DAF
1176
1177
1159 literal-string *literal-string* *E115* 1178 literal-string *literal-string* *E115*
1160 --------------- 1179 ---------------
1161 'string' string constant *expr-'* 1180 'string' string constant *expr-'*
1162 1181
1163 Note that single quotes are used. 1182 Note that single quotes are used.
1909 v:t_none Value of None type. Read-only. See: |type()| 1928 v:t_none Value of None type. Read-only. See: |type()|
1910 *v:t_number* *t_number-variable* 1929 *v:t_number* *t_number-variable*
1911 v:t_number Value of Number type. Read-only. See: |type()| 1930 v:t_number Value of Number type. Read-only. See: |type()|
1912 *v:t_string* *t_string-variable* 1931 *v:t_string* *t_string-variable*
1913 v:t_string Value of String type. Read-only. See: |type()| 1932 v:t_string Value of String type. Read-only. See: |type()|
1933 *v:t_blob* *t_blob-variable*
1934 v:t_blob Value of Blob type. Read-only. See: |type()|
1914 1935
1915 *v:termresponse* *termresponse-variable* 1936 *v:termresponse* *termresponse-variable*
1916 v:termresponse The escape sequence returned by the terminal for the |t_RV| 1937 v:termresponse The escape sequence returned by the terminal for the |t_RV|
1917 termcap entry. It is set when Vim receives an escape sequence 1938 termcap entry. It is set when Vim receives an escape sequence
1918 that starts with ESC [ or CSI and ends in a 'c', with only 1939 that starts with ESC [ or CSI and ends in a 'c', with only
2092 ch_log({msg} [, {handle}]) none write {msg} in the channel log file 2113 ch_log({msg} [, {handle}]) none write {msg} in the channel log file
2093 ch_logfile({fname} [, {mode}]) none start logging channel activity 2114 ch_logfile({fname} [, {mode}]) none start logging channel activity
2094 ch_open({address} [, {options}]) 2115 ch_open({address} [, {options}])
2095 Channel open a channel to {address} 2116 Channel open a channel to {address}
2096 ch_read({handle} [, {options}]) String read from {handle} 2117 ch_read({handle} [, {options}]) String read from {handle}
2118 ch_readblob({handle} [, {options}])
2119 Blob read Blob from {handle}
2097 ch_readraw({handle} [, {options}]) 2120 ch_readraw({handle} [, {options}])
2098 String read raw from {handle} 2121 String read raw from {handle}
2099 ch_sendexpr({handle}, {expr} [, {options}]) 2122 ch_sendexpr({handle}, {expr} [, {options}])
2100 any send {expr} over JSON {handle} 2123 any send {expr} over JSON {handle}
2101 ch_sendraw({handle}, {string} [, {options}]) 2124 ch_sendraw({handle}, {expr} [, {options}])
2102 any send {string} over raw {handle} 2125 any send {expr} over raw {handle}
2103 ch_setoptions({handle}, {options}) 2126 ch_setoptions({handle}, {options})
2104 none set options for {handle} 2127 none set options for {handle}
2105 ch_status({handle} [, {options}]) 2128 ch_status({handle} [, {options}])
2106 String status of channel {handle} 2129 String status of channel {handle}
2107 changenr() Number current change number 2130 changenr() Number current change number
2237 hlexists({name}) Number |TRUE| if highlight group {name} exists 2260 hlexists({name}) Number |TRUE| if highlight group {name} exists
2238 hlID({name}) Number syntax ID of highlight group {name} 2261 hlID({name}) Number syntax ID of highlight group {name}
2239 hostname() String name of the machine Vim is running on 2262 hostname() String name of the machine Vim is running on
2240 iconv({expr}, {from}, {to}) String convert encoding of {expr} 2263 iconv({expr}, {from}, {to}) String convert encoding of {expr}
2241 indent({lnum}) Number indent of line {lnum} 2264 indent({lnum}) Number indent of line {lnum}
2242 index({list}, {expr} [, {start} [, {ic}]]) 2265 index({object}, {expr} [, {start} [, {ic}]])
2243 Number index in {list} where {expr} appears 2266 Number index in {object} where {expr} appears
2244 input({prompt} [, {text} [, {completion}]]) 2267 input({prompt} [, {text} [, {completion}]])
2245 String get input from the user 2268 String get input from the user
2246 inputdialog({prompt} [, {text} [, {completion}]]) 2269 inputdialog({prompt} [, {text} [, {completion}]])
2247 String like input() but in a GUI dialog 2270 String like input() but in a GUI dialog
2248 inputlist({textlist}) Number let the user pick from a choice list 2271 inputlist({textlist}) Number let the user pick from a choice list
2249 inputrestore() Number restore typeahead 2272 inputrestore() Number restore typeahead
2250 inputsave() Number save and clear typeahead 2273 inputsave() Number save and clear typeahead
2251 inputsecret({prompt} [, {text}]) String like input() but hiding the text 2274 inputsecret({prompt} [, {text}]) String like input() but hiding the text
2252 insert({list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] 2275 insert({object}, {item} [, {idx}]) List insert {item} in {object} [before {idx}]
2253 invert({expr}) Number bitwise invert 2276 invert({expr}) Number bitwise invert
2254 isdirectory({directory}) Number |TRUE| if {directory} is a directory 2277 isdirectory({directory}) Number |TRUE| if {directory} is a directory
2255 islocked({expr}) Number |TRUE| if {expr} is locked 2278 islocked({expr}) Number |TRUE| if {expr} is locked
2256 isnan({expr}) Number |TRUE| if {expr} is NaN 2279 isnan({expr}) Number |TRUE| if {expr} is NaN
2257 items({dict}) List key-value pairs in {dict} 2280 items({dict}) List key-value pairs in {dict}
2337 pyeval({expr}) any evaluate |Python| expression 2360 pyeval({expr}) any evaluate |Python| expression
2338 py3eval({expr}) any evaluate |python3| expression 2361 py3eval({expr}) any evaluate |python3| expression
2339 pyxeval({expr}) any evaluate |python_x| expression 2362 pyxeval({expr}) any evaluate |python_x| expression
2340 range({expr} [, {max} [, {stride}]]) 2363 range({expr} [, {max} [, {stride}]])
2341 List items from {expr} to {max} 2364 List items from {expr} to {max}
2342 readfile({fname} [, {binary} [, {max}]]) 2365 readfile({fname} [, {type} [, {max}]])
2343 List get list of lines from file {fname} 2366 List get list of lines from file {fname}
2344 reg_executing() String get the executing register name 2367 reg_executing() String get the executing register name
2345 reg_recording() String get the recording register name 2368 reg_recording() String get the recording register name
2346 reltime([{start} [, {end}]]) List get time value 2369 reltime([{start} [, {end}]]) List get time value
2347 reltimefloat({time}) Float turn the time value into a Float 2370 reltimefloat({time}) Float turn the time value into a Float
2552 winrestcmd() String returns command to restore window sizes 2575 winrestcmd() String returns command to restore window sizes
2553 winrestview({dict}) none restore view of current window 2576 winrestview({dict}) none restore view of current window
2554 winsaveview() Dict save view of current window 2577 winsaveview() Dict save view of current window
2555 winwidth({nr}) Number width of window {nr} 2578 winwidth({nr}) Number width of window {nr}
2556 wordcount() Dict get byte/char/word statistics 2579 wordcount() Dict get byte/char/word statistics
2557 writefile({list}, {fname} [, {flags}]) 2580 writefile({object}, {fname} [, {flags}])
2558 Number write list of lines to file {fname} 2581 Number write |Blob| or |List| of lines to file
2559 xor({expr}, {expr}) Number bitwise XOR 2582 xor({expr}, {expr}) Number bitwise XOR
2560 2583
2561 2584
2562 abs({expr}) *abs()* 2585 abs({expr}) *abs()*
2563 Return the absolute value of {expr}. When {expr} evaluates to 2586 Return the absolute value of {expr}. When {expr} evaluates to
3197 For a NL channel this waits for a NL to arrive, except when 3220 For a NL channel this waits for a NL to arrive, except when
3198 there is nothing more to read (channel was closed). 3221 there is nothing more to read (channel was closed).
3199 See |channel-more|. 3222 See |channel-more|.
3200 {only available when compiled with the |+channel| feature} 3223 {only available when compiled with the |+channel| feature}
3201 3224
3225 ch_readblob({handle} [, {options}]) *ch_readblob()*
3226 Like ch_read() but reads binary data and returns a Blob.
3227 See |channel-more|.
3228 {only available when compiled with the |+channel| feature}
3229
3202 ch_readraw({handle} [, {options}]) *ch_readraw()* 3230 ch_readraw({handle} [, {options}]) *ch_readraw()*
3203 Like ch_read() but for a JS and JSON channel does not decode 3231 Like ch_read() but for a JS and JSON channel does not decode
3204 the message. For a NL channel it does not block waiting for 3232 the message. For a NL channel it does not block waiting for
3205 the NL to arrive, but otherwise works like ch_read(). 3233 the NL to arrive, but otherwise works like ch_read().
3206 See |channel-more|. 3234 See |channel-more|.
3213 See |channel-use|. *E912* 3241 See |channel-use|. *E912*
3214 {handle} can be a Channel or a Job that has a Channel. 3242 {handle} can be a Channel or a Job that has a Channel.
3215 3243
3216 {only available when compiled with the |+channel| feature} 3244 {only available when compiled with the |+channel| feature}
3217 3245
3218 ch_sendraw({handle}, {string} [, {options}]) *ch_sendraw()* 3246 ch_sendraw({handle}, {expr} [, {options}]) *ch_sendraw()*
3219 Send {string} over {handle}. 3247 Send string or Blob {expr} over {handle}.
3220 Works like |ch_sendexpr()|, but does not encode the request or 3248 Works like |ch_sendexpr()|, but does not encode the request or
3221 decode the response. The caller is responsible for the 3249 decode the response. The caller is responsible for the
3222 correct contents. Also does not add a newline for a channel 3250 correct contents. Also does not add a newline for a channel
3223 in NL mode, the caller must do that. The NL in the response 3251 in NL mode, the caller must do that. The NL in the response
3224 is removed. 3252 is removed.
5373 of 'tabstop' is relevant. {lnum} is used just like in 5401 of 'tabstop' is relevant. {lnum} is used just like in
5374 |getline()|. 5402 |getline()|.
5375 When {lnum} is invalid -1 is returned. 5403 When {lnum} is invalid -1 is returned.
5376 5404
5377 5405
5378 index({list}, {expr} [, {start} [, {ic}]]) *index()* 5406 index({object}, {expr} [, {start} [, {ic}]]) *index()*
5379 Return the lowest index in |List| {list} where the item has a 5407 If {object} is a |List| return the lowest index where the item
5380 value equal to {expr}. There is no automatic conversion, so 5408 has a value equal to {expr}. There is no automatic
5381 the String "4" is different from the Number 4. And the number 5409 conversion, so the String "4" is different from the Number 4.
5382 4 is different from the Float 4.0. The value of 'ignorecase' 5410 And the number 4 is different from the Float 4.0. The value
5383 is not used here, case always matters. 5411 of 'ignorecase' is not used here, case always matters.
5412
5413 If {object} is |Blob| return the lowest index where the byte
5414 value is equal to {expr}.
5415
5384 If {start} is given then start looking at the item with index 5416 If {start} is given then start looking at the item with index
5385 {start} (may be negative for an item relative to the end). 5417 {start} (may be negative for an item relative to the end).
5386 When {ic} is given and it is |TRUE|, ignore case. Otherwise 5418 When {ic} is given and it is |TRUE|, ignore case. Otherwise
5387 case must match. 5419 case must match.
5388 -1 is returned when {expr} is not found in {list}. 5420 -1 is returned when {expr} is not found in {object}.
5389 Example: > 5421 Example: >
5390 :let idx = index(words, "the") 5422 :let idx = index(words, "the")
5391 :if index(numbers, 123) >= 0 5423 :if index(numbers, 123) >= 0
5392 5424
5393 5425
5489 |history| stack. 5521 |history| stack.
5490 The result is a String, which is whatever the user actually 5522 The result is a String, which is whatever the user actually
5491 typed on the command-line in response to the issued prompt. 5523 typed on the command-line in response to the issued prompt.
5492 NOTE: Command-line completion is not supported. 5524 NOTE: Command-line completion is not supported.
5493 5525
5494 insert({list}, {item} [, {idx}]) *insert()* 5526 insert({object}, {item} [, {idx}]) *insert()*
5495 Insert {item} at the start of |List| {list}. 5527 When {object} is a |List| or a |Blob| insert {item} at the start
5528 of it.
5529
5496 If {idx} is specified insert {item} before the item with index 5530 If {idx} is specified insert {item} before the item with index
5497 {idx}. If {idx} is zero it goes before the first item, just 5531 {idx}. If {idx} is zero it goes before the first item, just
5498 like omitting {idx}. A negative {idx} is also possible, see 5532 like omitting {idx}. A negative {idx} is also possible, see
5499 |list-index|. -1 inserts just before the last item. 5533 |list-index|. -1 inserts just before the last item.
5500 Returns the resulting |List|. Examples: > 5534
5535 Returns the resulting |List| or |Blob|. Examples: >
5501 :let mylist = insert([2, 3, 5], 1) 5536 :let mylist = insert([2, 3, 5], 1)
5502 :call insert(mylist, 4, -1) 5537 :call insert(mylist, 4, -1)
5503 :call insert(mylist, 6, len(mylist)) 5538 :call insert(mylist, 6, len(mylist))
5504 < The last example can be done simpler with |add()|. 5539 < The last example can be done simpler with |add()|.
5505 Note that when {item} is a |List| it is inserted as a single 5540 Note that when {item} is a |List| it is inserted as a single
5761 Funcref not possible, error 5796 Funcref not possible, error
5762 List as an array (possibly null); when 5797 List as an array (possibly null); when
5763 used recursively: [] 5798 used recursively: []
5764 Dict as an object (possibly null); when 5799 Dict as an object (possibly null); when
5765 used recursively: {} 5800 used recursively: {}
5801 Blob as an array of the individual bytes
5766 v:false "false" 5802 v:false "false"
5767 v:true "true" 5803 v:true "true"
5768 v:none "null" 5804 v:none "null"
5769 v:null "null" 5805 v:null "null"
5770 Note that NaN and Infinity are passed on as values. This is 5806 Note that NaN and Infinity are passed on as values. This is
6945 range(2, -2, -1) " [2, 1, 0, -1, -2] 6981 range(2, -2, -1) " [2, 1, 0, -1, -2]
6946 range(0) " [] 6982 range(0) " []
6947 range(2, 0) " error! 6983 range(2, 0) " error!
6948 < 6984 <
6949 *readfile()* 6985 *readfile()*
6950 readfile({fname} [, {binary} [, {max}]]) 6986 readfile({fname} [, {type} [, {max}]])
6951 Read file {fname} and return a |List|, each line of the file 6987 Read file {fname} and return a |List|, each line of the file
6952 as an item. Lines are broken at NL characters. Macintosh 6988 as an item. Lines are broken at NL characters. Macintosh
6953 files separated with CR will result in a single long line 6989 files separated with CR will result in a single long line
6954 (unless a NL appears somewhere). 6990 (unless a NL appears somewhere).
6955 All NUL characters are replaced with a NL character. 6991 All NUL characters are replaced with a NL character.
6956 When {binary} contains "b" binary mode is used: 6992 When {type} contains "b" binary mode is used:
6957 - When the last line ends in a NL an extra empty list item is 6993 - When the last line ends in a NL an extra empty list item is
6958 added. 6994 added.
6959 - No CR characters are removed. 6995 - No CR characters are removed.
6996 When {type} contains "B" a |Blob| is returned with the binary
6997 data of the file unmodified.
6960 Otherwise: 6998 Otherwise:
6961 - CR characters that appear before a NL are removed. 6999 - CR characters that appear before a NL are removed.
6962 - Whether the last line ends in a NL or not does not matter. 7000 - Whether the last line ends in a NL or not does not matter.
6963 - When 'encoding' is Unicode any UTF-8 byte order mark is 7001 - When 'encoding' is Unicode any UTF-8 byte order mark is
6964 removed from the text. 7002 removed from the text.
7130 points to an item before {idx} this is an error. 7168 points to an item before {idx} this is an error.
7131 See |list-index| for possible values of {idx} and {end}. 7169 See |list-index| for possible values of {idx} and {end}.
7132 Example: > 7170 Example: >
7133 :echo "last item: " . remove(mylist, -1) 7171 :echo "last item: " . remove(mylist, -1)
7134 :call remove(mylist, 0, 9) 7172 :call remove(mylist, 0, 9)
7173 remove({blob}, {idx} [, {end}])
7174 Without {end}: Remove the byte at {idx} from |Blob| {blob} and
7175 return the byte.
7176 With {end}: Remove bytes from {idx} to {end} (inclusive) and
7177 return a |Blob| with these bytes. When {idx} points to the same
7178 byte as {end} a |Blob| with one byte is returned. When {end}
7179 points to a byte before {idx} this is an error.
7180 Example: >
7181 :echo "last byte: " . remove(myblob, -1)
7182 :call remove(mylist, 0, 9)
7135 remove({dict}, {key}) 7183 remove({dict}, {key})
7136 Remove the entry from {dict} with key {key}. Example: > 7184 Remove the entry from {dict} with key {key}. Example: >
7137 :echo "removed " . remove(dict, "one") 7185 :echo "removed " . remove(dict, "one")
7138 < If there is no {key} in {dict} this is an error. 7186 < If there is no {key} in {dict} this is an error.
7139 7187
7170 resolve() keeps a leading path component specifying the 7218 resolve() keeps a leading path component specifying the
7171 current directory (provided the result is still a relative 7219 current directory (provided the result is still a relative
7172 path name) and also keeps a trailing path separator. 7220 path name) and also keeps a trailing path separator.
7173 7221
7174 *reverse()* 7222 *reverse()*
7175 reverse({list}) Reverse the order of items in {list} in-place. Returns 7223 reverse({object})
7176 {list}. 7224 Reverse the order of items in {object} in-place.
7177 If you want a list to remain unmodified make a copy first: > 7225 {object} can be a |List| or a |Blob|.
7226 Returns {object}.
7227 If you want an object to remain unmodified make a copy first: >
7178 :let revlist = reverse(copy(mylist)) 7228 :let revlist = reverse(copy(mylist))
7179 7229
7180 round({expr}) *round()* 7230 round({expr}) *round()*
7181 Round off {expr} to the nearest integral value and return it 7231 Round off {expr} to the nearest integral value and return it
7182 as a |Float|. If {expr} lies halfway between two integral 7232 as a |Float|. If {expr} lies halfway between two integral
9516 Float: 5 |v:t_float| 9566 Float: 5 |v:t_float|
9517 Boolean: 6 |v:t_bool| (v:false and v:true) 9567 Boolean: 6 |v:t_bool| (v:false and v:true)
9518 None 7 |v:t_none| (v:null and v:none) 9568 None 7 |v:t_none| (v:null and v:none)
9519 Job 8 |v:t_job| 9569 Job 8 |v:t_job|
9520 Channel 9 |v:t_channel| 9570 Channel 9 |v:t_channel|
9571 Blob 10 |v:t_blob|
9521 For backward compatibility, this method can be used: > 9572 For backward compatibility, this method can be used: >
9522 :if type(myvar) == type(0) 9573 :if type(myvar) == type(0)
9523 :if type(myvar) == type("") 9574 :if type(myvar) == type("")
9524 :if type(myvar) == type(function("tr")) 9575 :if type(myvar) == type(function("tr"))
9525 :if type(myvar) == type([]) 9576 :if type(myvar) == type([])
9863 visual_words Number of words visually selected 9914 visual_words Number of words visually selected
9864 (only in Visual mode) 9915 (only in Visual mode)
9865 9916
9866 9917
9867 *writefile()* 9918 *writefile()*
9868 writefile({list}, {fname} [, {flags}]) 9919 writefile({object}, {fname} [, {flags}])
9869 Write |List| {list} to file {fname}. Each list item is 9920 When {object} is a |List| write it to file {fname}. Each list
9870 separated with a NL. Each list item must be a String or 9921 item is separated with a NL. Each list item must be a String
9871 Number. 9922 or Number.
9872 When {flags} contains "b" then binary mode is used: There will 9923 When {flags} contains "b" then binary mode is used: There will
9873 not be a NL after the last list item. An empty item at the 9924 not be a NL after the last list item. An empty item at the
9874 end does cause the last line in the file to end in a NL. 9925 end does cause the last line in the file to end in a NL.
9926
9927 When {object} is a |Blob| write the bytes to file {fname}
9928 unmodified.
9875 9929
9876 When {flags} contains "a" then append mode is used, lines are 9930 When {flags} contains "a" then append mode is used, lines are
9877 appended to the file: > 9931 appended to the file: >
9878 :call writefile(["foo"], "event.log", "a") 9932 :call writefile(["foo"], "event.log", "a")
9879 :call writefile(["bar"], "event.log", "a") 9933 :call writefile(["bar"], "event.log", "a")
10573 the index can be repeated. 10627 the index can be repeated.
10574 This cannot be used to add an item to a |List|. 10628 This cannot be used to add an item to a |List|.
10575 This cannot be used to set a byte in a String. You 10629 This cannot be used to set a byte in a String. You
10576 can do that like this: > 10630 can do that like this: >
10577 :let var = var[0:2] . 'X' . var[4:] 10631 :let var = var[0:2] . 'X' . var[4:]
10578 < 10632 < When {var-name} is a |Blob| then {idx} can be the
10633 length of the blob, in which case one byte is
10634 appended.
10635
10579 *E711* *E719* 10636 *E711* *E719*
10580 :let {var-name}[{idx1}:{idx2}] = {expr1} *E708* *E709* *E710* 10637 :let {var-name}[{idx1}:{idx2}] = {expr1} *E708* *E709* *E710*
10581 Set a sequence of items in a |List| to the result of 10638 Set a sequence of items in a |List| to the result of
10582 the expression {expr1}, which must be a list with the 10639 the expression {expr1}, which must be a list with the
10583 correct number of items. 10640 correct number of items.