Mercurial > vim
comparison runtime/doc/eval.txt @ 23602:7b3317e959e3 v8.2.2343
patch 8.2.2343: Vim9: return type of readfile() is any
Commit: https://github.com/vim/vim/commit/c423ad77ed763c11ba67729bbf63c1cf0915231f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 13 20:38:03 2021 +0100
patch 8.2.2343: Vim9: return type of readfile() is any
Problem: Vim9: return type of readfile() is any.
Solution: Add readblob() so that readfile() can be expected to always
return a list of strings. (closes #7671)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 13 Jan 2021 20:45:04 +0100 |
parents | d3e064f54890 |
children | 1816ea68c022 |
comparison
equal
deleted
inserted
replaced
23601:3b600f015796 | 23602:7b3317e959e3 |
---|---|
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 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
2773 pyeval({expr}) any evaluate |Python| expression | 2773 pyeval({expr}) any evaluate |Python| expression |
2774 pyxeval({expr}) any evaluate |python_x| expression | 2774 pyxeval({expr}) any evaluate |python_x| expression |
2775 rand([{expr}]) Number get pseudo-random number | 2775 rand([{expr}]) Number get pseudo-random number |
2776 range({expr} [, {max} [, {stride}]]) | 2776 range({expr} [, {max} [, {stride}]]) |
2777 List items from {expr} to {max} | 2777 List items from {expr} to {max} |
2778 readblob({fname}) Blob read a |Blob| from {fname} | |
2778 readdir({dir} [, {expr} [, {dict}]]) | 2779 readdir({dir} [, {expr} [, {dict}]]) |
2779 List file names in {dir} selected by {expr} | 2780 List file names in {dir} selected by {expr} |
2780 readdirex({dir} [, {expr} [, {dict}]]) | 2781 readdirex({dir} [, {expr} [, {dict}]]) |
2781 List file info in {dir} selected by {expr} | 2782 List file info in {dir} selected by {expr} |
2782 readfile({fname} [, {type} [, {max}]]) | 2783 readfile({fname} [, {type} [, {max}]]) |
8263 :echo rand() | 8264 :echo rand() |
8264 :let seed = srand() | 8265 :let seed = srand() |
8265 :echo rand(seed) | 8266 :echo rand(seed) |
8266 :echo rand(seed) % 16 " random number 0 - 15 | 8267 :echo rand(seed) % 16 " random number 0 - 15 |
8267 < | 8268 < |
8269 | |
8270 readblob({fname}) *readblob()* | |
8271 Read file {fname} in binary mode and return a |Blob|. | |
8272 When the file can't be opened an error message is given and | |
8273 the result is an empty |Blob|. | |
8274 Also see |readfile()| and |writefile()|. | |
8275 | |
8276 | |
8268 readdir({directory} [, {expr} [, {dict}]]) *readdir()* | 8277 readdir({directory} [, {expr} [, {dict}]]) *readdir()* |
8269 Return a list with file and directory names in {directory}. | 8278 Return a list with file and directory names in {directory}. |
8270 You can also use |glob()| if you don't need to do complicated | 8279 You can also use |glob()| if you don't need to do complicated |
8271 things, such as limiting the number of matches. | 8280 things, such as limiting the number of matches. |
8272 The list will be sorted (case sensitive), see the {dict} | 8281 The list will be sorted (case sensitive), see the {dict} |
8377 | 8386 |
8378 < | 8387 < |
8379 Can also be used as a |method|: > | 8388 Can also be used as a |method|: > |
8380 GetDirName()->readdirex() | 8389 GetDirName()->readdirex() |
8381 < | 8390 < |
8391 | |
8382 *readfile()* | 8392 *readfile()* |
8383 readfile({fname} [, {type} [, {max}]]) | 8393 readfile({fname} [, {type} [, {max}]]) |
8384 Read file {fname} and return a |List|, each line of the file | 8394 Read file {fname} and return a |List|, each line of the file |
8385 as an item. Lines are broken at NL characters. Macintosh | 8395 as an item. Lines are broken at NL characters. Macintosh |
8386 files separated with CR will result in a single long line | 8396 files separated with CR will result in a single long line |
8388 All NUL characters are replaced with a NL character. | 8398 All NUL characters are replaced with a NL character. |
8389 When {type} contains "b" binary mode is used: | 8399 When {type} contains "b" binary mode is used: |
8390 - When the last line ends in a NL an extra empty list item is | 8400 - When the last line ends in a NL an extra empty list item is |
8391 added. | 8401 added. |
8392 - No CR characters are removed. | 8402 - No CR characters are removed. |
8393 When {type} contains "B" a |Blob| is returned with the binary | |
8394 data of the file unmodified. | |
8395 Otherwise: | 8403 Otherwise: |
8396 - CR characters that appear before a NL are removed. | 8404 - CR characters that appear before a NL are removed. |
8397 - Whether the last line ends in a NL or not does not matter. | 8405 - Whether the last line ends in a NL or not does not matter. |
8398 - When 'encoding' is Unicode any UTF-8 byte order mark is | 8406 - When 'encoding' is Unicode any UTF-8 byte order mark is |
8399 removed from the text. | 8407 removed from the text. |
8407 are returned, or as many as there are. | 8415 are returned, or as many as there are. |
8408 When {max} is zero the result is an empty list. | 8416 When {max} is zero the result is an empty list. |
8409 Note that without {max} the whole file is read into memory. | 8417 Note that without {max} the whole file is read into memory. |
8410 Also note that there is no recognition of encoding. Read a | 8418 Also note that there is no recognition of encoding. Read a |
8411 file into a buffer if you need to. | 8419 file into a buffer if you need to. |
8420 Deprecated (use |readblob()| instead): When {type} contains | |
8421 "B" a |Blob| is returned with the binary data of the file | |
8422 unmodified. | |
8412 When the file can't be opened an error message is given and | 8423 When the file can't be opened an error message is given and |
8413 the result is an empty list. | 8424 the result is an empty list. |
8414 Also see |writefile()|. | 8425 Also see |writefile()|. |
8415 | 8426 |
8416 Can also be used as a |method|: > | 8427 Can also be used as a |method|: > |
11293 effects. Use |:noautocmd| if needed. | 11304 effects. Use |:noautocmd| if needed. |
11294 Example: > | 11305 Example: > |
11295 call win_execute(winid, 'set syntax=python') | 11306 call win_execute(winid, 'set syntax=python') |
11296 < Doing the same with `setwinvar()` would not trigger | 11307 < Doing the same with `setwinvar()` would not trigger |
11297 autocommands and not actually show syntax highlighting. | 11308 autocommands and not actually show syntax highlighting. |
11309 | |
11298 *E994* | 11310 *E994* |
11299 Not all commands are allowed in popup windows. | 11311 Not all commands are allowed in popup windows. |
11300 When window {id} does not exist then no error is given. | 11312 When window {id} does not exist then no error is given and |
11313 an empty string is returned. | |
11301 | 11314 |
11302 Can also be used as a |method|, the base is passed as the | 11315 Can also be used as a |method|, the base is passed as the |
11303 second argument: > | 11316 second argument: > |
11304 GetCommand()->win_execute(winid) | 11317 GetCommand()->win_execute(winid) |
11305 | 11318 |