Mercurial > vim
comparison runtime/doc/eval.txt @ 17758:f2c2f9126a82
Update runtime files.
commit https://github.com/vim/vim/commit/56c860c315c517d304320e12bf7b5c1479546dae
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 17 20:09:31 2019 +0200
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 17 Aug 2019 20:15:03 +0200 |
parents | a7afcea6f40a |
children | 545119cd5554 |
comparison
equal
deleted
inserted
replaced
17757:39fe82460b5d | 17758:f2c2f9126a82 |
---|---|
1 *eval.txt* For Vim version 8.1. Last change: 2019 Aug 08 | 1 *eval.txt* For Vim version 8.1. Last change: 2019 Aug 17 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
481 A key is always a String. You can use a Number, it will be converted to a | 481 A key is always a String. You can use a Number, it will be converted to a |
482 String automatically. Thus the String '4' and the number 4 will find the same | 482 String automatically. Thus the String '4' and the number 4 will find the same |
483 entry. Note that the String '04' and the Number 04 are different, since the | 483 entry. Note that the String '04' and the Number 04 are different, since the |
484 Number will be converted to the String '4'. The empty string can also be used | 484 Number will be converted to the String '4'. The empty string can also be used |
485 as a key. | 485 as a key. |
486 *literal-Dict* | 486 *literal-Dict* *#{}* |
487 To avoid having to put quotes around every key the #{} form can be used. This | 487 To avoid having to put quotes around every key the #{} form can be used. This |
488 does require the key to consist only of ASCII letters, digits, '-' and '_'. | 488 does require the key to consist only of ASCII letters, digits, '-' and '_'. |
489 Example: > | 489 Example: > |
490 let mydict = #{zero: 0, one_key: 1, two-key: 2, 333: 3} | 490 let mydict = #{zero: 0, one_key: 1, two-key: 2, 333: 3} |
491 Note that 333 here is the string "333". Empty keys are not possible with #{}. | 491 Note that 333 here is the string "333". Empty keys are not possible with #{}. |
1217 When expr8 is a |Funcref| type variable, invoke the function it refers to. | 1217 When expr8 is a |Funcref| type variable, invoke the function it refers to. |
1218 | 1218 |
1219 | 1219 |
1220 expr8->name([args]) method call *method* *->* | 1220 expr8->name([args]) method call *method* *->* |
1221 expr8->{lambda}([args]) | 1221 expr8->{lambda}([args]) |
1222 | 1222 *E276* |
1223 For methods that are also available as global functions this is the same as: > | 1223 For methods that are also available as global functions this is the same as: > |
1224 name(expr8 [, args]) | 1224 name(expr8 [, args]) |
1225 There can also be methods specifically for the type of "expr8". | 1225 There can also be methods specifically for the type of "expr8". |
1226 | 1226 |
1227 This allows for chaining, passing the value that one method returns to the | 1227 This allows for chaining, passing the value that one method returns to the |
1228 next method: > | 1228 next method: > |
1229 mylist->filter(filterexpr)->map(mapexpr)->sort()->join() | 1229 mylist->filter(filterexpr)->map(mapexpr)->sort()->join() |
1230 < | 1230 < |
1231 Example of using a lambda: > | 1231 Example of using a lambda: > |
1232 GetPercentage->{x -> x * 100}()->printf('%d%%') | 1232 GetPercentage->{x -> x * 100}()->printf('%d%%') |
1233 | 1233 < |
1234 *E274* | 1234 *E274* |
1235 "->name(" must not contain white space. There can be white space before the | 1235 "->name(" must not contain white space. There can be white space before the |
1236 "->" and after the "(", thus you can split the lines like this: > | 1236 "->" and after the "(", thus you can split the lines like this: > |
1237 mylist | 1237 mylist |
1238 \ ->filter(filterexpr) | 1238 \ ->filter(filterexpr) |
1239 \ ->map(mapexpr) | 1239 \ ->map(mapexpr) |
1240 \ ->sort() | 1240 \ ->sort() |
1241 \ ->join() | 1241 \ ->join() |
1242 < | 1242 |
1243 When using the lambda form there must be no white space between the } and the | |
1244 (. | |
1245 | |
1243 | 1246 |
1244 *expr9* | 1247 *expr9* |
1245 number | 1248 number |
1246 ------ | 1249 ------ |
1247 number number constant *expr-number* | 1250 number number constant *expr-number* |
2033 invoked. Allows you to do special initialisations for |view|, | 2036 invoked. Allows you to do special initialisations for |view|, |
2034 |evim| etc., or any other name you might symlink to Vim. | 2037 |evim| etc., or any other name you might symlink to Vim. |
2035 Read-only. | 2038 Read-only. |
2036 | 2039 |
2037 *v:progpath* *progpath-variable* | 2040 *v:progpath* *progpath-variable* |
2038 v:progpath Contains the command with which Vim was invoked, including the | 2041 v:progpath Contains the command with which Vim was invoked, in a form |
2039 path. Useful if you want to message a Vim server using a | 2042 that when passed to the shell will run the same Vim executable |
2043 as the current one (if $PATH remains unchanged). | |
2044 Useful if you want to message a Vim server using a | |
2040 |--remote-expr|. | 2045 |--remote-expr|. |
2041 To get the full path use: > | 2046 To get the full path use: > |
2042 echo exepath(v:progpath) | 2047 echo exepath(v:progpath) |
2043 < If the path is relative it will be expanded to the full path, | 2048 < If the command has a relative path it will be expanded to the |
2044 so that it still works after `:cd`. Thus starting "./vim" | 2049 full path, so that it still works after `:cd`. Thus starting |
2045 results in "/home/user/path/to/vim/src/vim". | 2050 "./vim" results in "/home/user/path/to/vim/src/vim". |
2051 On Linux and other systems it will always be the full path. | |
2052 On Mac it may just be "vim" and using exepath() as mentioned | |
2053 above should be used to get the full path. | |
2046 On MS-Windows the executable may be called "vim.exe", but the | 2054 On MS-Windows the executable may be called "vim.exe", but the |
2047 ".exe" is not added to v:progpath. | 2055 ".exe" is not added to v:progpath. |
2048 Read-only. | 2056 Read-only. |
2049 | 2057 |
2050 *v:register* *register-variable* | 2058 *v:register* *register-variable* |
9318 call win_execute(winid, 'set syntax=python') | 9326 call win_execute(winid, 'set syntax=python') |
9319 < Doing the same with `setwinvar()` would not trigger | 9327 < Doing the same with `setwinvar()` would not trigger |
9320 autocommands and not actually show syntax highlighting. | 9328 autocommands and not actually show syntax highlighting. |
9321 *E994* | 9329 *E994* |
9322 Not all commands are allowed in popup windows. | 9330 Not all commands are allowed in popup windows. |
9331 When window {id} does not exist then no error is given. | |
9323 | 9332 |
9324 win_findbuf({bufnr}) *win_findbuf()* | 9333 win_findbuf({bufnr}) *win_findbuf()* |
9325 Returns a list with |window-ID|s for windows that contain | 9334 Returns a list with |window-ID|s for windows that contain |
9326 buffer {bufnr}. When there is none the list is empty. | 9335 buffer {bufnr}. When there is none the list is empty. |
9327 | 9336 |
10339 | 10348 |
10340 | 10349 |
10341 :let ${env-name} = {expr1} *:let-environment* *:let-$* | 10350 :let ${env-name} = {expr1} *:let-environment* *:let-$* |
10342 Set environment variable {env-name} to the result of | 10351 Set environment variable {env-name} to the result of |
10343 the expression {expr1}. The type is always String. | 10352 the expression {expr1}. The type is always String. |
10353 | |
10354 On some systems making an environment variable empty | |
10355 causes it to be deleted. Many systems do not make a | |
10356 difference between an environment variable that is not | |
10357 set and an environment variable that is empty. | |
10358 | |
10344 :let ${env-name} .= {expr1} | 10359 :let ${env-name} .= {expr1} |
10345 Append {expr1} to the environment variable {env-name}. | 10360 Append {expr1} to the environment variable {env-name}. |
10346 If the environment variable didn't exist yet this | 10361 If the environment variable didn't exist yet this |
10347 works like "=". | 10362 works like "=". |
10348 | 10363 |