Mercurial > vim
comparison runtime/doc/eval.txt @ 16808:c002c4899529
Update runtime files.
commit https://github.com/vim/vim/commit/68e6560b84f196c82e27a72669684d5506a3a837
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 26 21:33:31 2019 +0200
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 May 2019 21:45:07 +0200 |
parents | a927fdf9a4b0 |
children | 6699c03347d2 |
comparison
equal
deleted
inserted
replaced
16807:ce0eea70294d | 16808:c002c4899529 |
---|---|
1 *eval.txt* For Vim version 8.1. Last change: 2019 May 09 | 1 *eval.txt* For Vim version 8.1. Last change: 2019 May 25 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
1188 | 1188 |
1189 There must not be white space before or after the dot. | 1189 There must not be white space before or after the dot. |
1190 | 1190 |
1191 Examples: > | 1191 Examples: > |
1192 :let dict = {"one": 1, 2: "two"} | 1192 :let dict = {"one": 1, 2: "two"} |
1193 :echo dict.one | 1193 :echo dict.one " shows "1" |
1194 :echo dict .2 | 1194 :echo dict.2 " shows "two" |
1195 :echo dict .2 " error because of space before the dot | |
1195 | 1196 |
1196 Note that the dot is also used for String concatenation. To avoid confusion | 1197 Note that the dot is also used for String concatenation. To avoid confusion |
1197 always put spaces around the dot for String concatenation. | 1198 always put spaces around the dot for String concatenation. |
1198 | 1199 |
1199 | 1200 |
3505 this to another chdir() to restore the directory. | 3506 this to another chdir() to restore the directory. |
3506 On failure, returns an empty string. | 3507 On failure, returns an empty string. |
3507 | 3508 |
3508 Example: > | 3509 Example: > |
3509 let save_dir = chdir(newdir) | 3510 let save_dir = chdir(newdir) |
3510 if save_dir | 3511 if save_dir != "" |
3511 " ... do some work | 3512 " ... do some work |
3512 call chdir(save_dir) | 3513 call chdir(save_dir) |
3513 endif | 3514 endif |
3514 < | 3515 < |
3515 cindent({lnum}) *cindent()* | 3516 cindent({lnum}) *cindent()* |
5124 |getqflist()| for the supported items in {what}. | 5125 |getqflist()| for the supported items in {what}. |
5125 | 5126 |
5126 In addition to the items supported by |getqflist()| in {what}, | 5127 In addition to the items supported by |getqflist()| in {what}, |
5127 the following item is supported by |getloclist()|: | 5128 the following item is supported by |getloclist()|: |
5128 | 5129 |
5129 filewinid id of the window used to display files | 5130 filewinid id of the window used to display files |
5130 from the location list. This field is | 5131 from the location list. This field is |
5131 applicable only when called from a | 5132 applicable only when called from a |
5132 location list window. See | 5133 location list window. See |
5133 |location-list-file-window| for more | 5134 |location-list-file-window| for more |
5134 details. | 5135 details. |
6347 col first column in "lnum" that was affected by | 6348 col first column in "lnum" that was affected by |
6348 the change; one if unknown or the whole line | 6349 the change; one if unknown or the whole line |
6349 was affected; this is a byte index, first | 6350 was affected; this is a byte index, first |
6350 character has a value of one. | 6351 character has a value of one. |
6351 When lines are inserted the values are: | 6352 When lines are inserted the values are: |
6352 lnum line below which the new line is added | 6353 lnum line above which the new line is added |
6353 end equal to "lnum" | 6354 end equal to "lnum" |
6354 added number of lines inserted | 6355 added number of lines inserted |
6355 col 1 | 6356 col 1 |
6356 When lines are deleted the values are: | 6357 When lines are deleted the values are: |
6357 lnum the first deleted line | 6358 lnum the first deleted line |
7334 type remove text properties with this type name | 7335 type remove text properties with this type name |
7335 bufnr use this buffer instead of the current one | 7336 bufnr use this buffer instead of the current one |
7336 all when TRUE remove all matching text properties, | 7337 all when TRUE remove all matching text properties, |
7337 not just the first one | 7338 not just the first one |
7338 A property matches when either "id" or "type" matches. | 7339 A property matches when either "id" or "type" matches. |
7340 If buffer "bufnr" does not exist you get an error message. | |
7341 If buffer 'bufnr" is not loaded then nothing happens. | |
7339 | 7342 |
7340 Returns the number of properties that were removed. | 7343 Returns the number of properties that were removed. |
7341 | 7344 |
7342 See |text-properties| for information about text properties. | 7345 See |text-properties| for information about text properties. |
7343 | 7346 |
10072 let timer = timer_start(500, 'MyHandler', | 10075 let timer = timer_start(500, 'MyHandler', |
10073 \ {'repeat': 3}) | 10076 \ {'repeat': 3}) |
10074 < This will invoke MyHandler() three times at 500 msec | 10077 < This will invoke MyHandler() three times at 500 msec |
10075 intervals. | 10078 intervals. |
10076 | 10079 |
10080 Not available in the |sandbox|. | |
10077 {only available when compiled with the |+timers| feature} | 10081 {only available when compiled with the |+timers| feature} |
10078 | 10082 |
10079 timer_stop({timer}) *timer_stop()* | 10083 timer_stop({timer}) *timer_stop()* |
10080 Stop a timer. The timer callback will no longer be invoked. | 10084 Stop a timer. The timer callback will no longer be invoked. |
10081 {timer} is an ID returned by timer_start(), thus it must be a | 10085 {timer} is an ID returned by timer_start(), thus it must be a |
11017 | 11021 |
11018 *optional-function-argument* | 11022 *optional-function-argument* |
11019 You can provide default values for positional named arguments. This makes | 11023 You can provide default values for positional named arguments. This makes |
11020 them optional for function calls. When a positional argument is not | 11024 them optional for function calls. When a positional argument is not |
11021 specified at a call, the default expression is used to initialize it. | 11025 specified at a call, the default expression is used to initialize it. |
11022 This only works for functions declared with |function|, not for lambda | 11026 This only works for functions declared with `:function`, not for lambda |
11023 expressions |expr-lambda|. | 11027 expressions |expr-lambda|. |
11024 | 11028 |
11025 Example: > | 11029 Example: > |
11026 function Something(key, value = 10) | 11030 function Something(key, value = 10) |
11027 echo a:key .. ": " .. a:value | 11031 echo a:key .. ": " .. a:value |
11029 call Something('empty') "empty: 10" | 11033 call Something('empty') "empty: 10" |
11030 call Something('key', 20) "key: 20" | 11034 call Something('key', 20) "key: 20" |
11031 | 11035 |
11032 The argument default expressions are evaluated at the time of the function | 11036 The argument default expressions are evaluated at the time of the function |
11033 call, not definition. Thus it is possible to use an expression which is | 11037 call, not definition. Thus it is possible to use an expression which is |
11034 invalid the moment the function is defined. The expressions are are also only | 11038 invalid the moment the function is defined. The expressions are also only |
11035 evaluated when arguments are not specified during a call. | 11039 evaluated when arguments are not specified during a call. |
11036 | 11040 |
11037 You can pass |v:none| to use the default expression. Note that this means you | 11041 You can pass |v:none| to use the default expression. Note that this means you |
11038 cannot pass v:none as an ordinary value when an argument has a default | 11042 cannot pass v:none as an ordinary value when an argument has a default |
11039 expression. | 11043 expression. |
11096 :endif | 11100 :endif |
11097 < | 11101 < |
11098 *:cal* *:call* *E107* *E117* | 11102 *:cal* *:call* *E107* *E117* |
11099 :[range]cal[l] {name}([arguments]) | 11103 :[range]cal[l] {name}([arguments]) |
11100 Call a function. The name of the function and its arguments | 11104 Call a function. The name of the function and its arguments |
11101 are as specified with |:function|. Up to 20 arguments can be | 11105 are as specified with `:function`. Up to 20 arguments can be |
11102 used. The returned value is discarded. | 11106 used. The returned value is discarded. |
11103 Without a range and for functions that accept a range, the | 11107 Without a range and for functions that accept a range, the |
11104 function is called once. When a range is given the cursor is | 11108 function is called once. When a range is given the cursor is |
11105 positioned at the start of the first line before executing the | 11109 positioned at the start of the first line before executing the |
11106 function. | 11110 function. |
11150 Using an autocommand ~ | 11154 Using an autocommand ~ |
11151 | 11155 |
11152 This is introduced in the user manual, section |41.14|. | 11156 This is introduced in the user manual, section |41.14|. |
11153 | 11157 |
11154 The autocommand is useful if you have a plugin that is a long Vim script file. | 11158 The autocommand is useful if you have a plugin that is a long Vim script file. |
11155 You can define the autocommand and quickly quit the script with |:finish|. | 11159 You can define the autocommand and quickly quit the script with `:finish`. |
11156 That makes Vim startup faster. The autocommand should then load the same file | 11160 That makes Vim startup faster. The autocommand should then load the same file |
11157 again, setting a variable to skip the |:finish| command. | 11161 again, setting a variable to skip the `:finish` command. |
11158 | 11162 |
11159 Use the FuncUndefined autocommand event with a pattern that matches the | 11163 Use the FuncUndefined autocommand event with a pattern that matches the |
11160 function(s) to be defined. Example: > | 11164 function(s) to be defined. Example: > |
11161 | 11165 |
11162 :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim | 11166 :au FuncUndefined BufNet* source ~/vim/bufnetfuncs.vim |
12999 command. Can be used to go back to old syntax for a range of lines. | 13003 command. Can be used to go back to old syntax for a range of lines. |
13000 Test for support with: > | 13004 Test for support with: > |
13001 has('vimscript-1') | 13005 has('vimscript-1') |
13002 | 13006 |
13003 :scriptversion 2 | 13007 :scriptversion 2 |
13004 < String concatenation with "." is not supported, use ".." instead. | 13008 < String concatenation with "." is not supported, use ".." instead. |
13005 This avoids the ambiguity using "." for Dict member access and | 13009 This avoids the ambiguity using "." for Dict member access and |
13006 floating point numbers. Now ".5" means the number 0.5. | 13010 floating point numbers. Now ".5" means the number 0.5. |
13007 > | 13011 > |
13008 :scriptversion 3 | 13012 :scriptversion 3 |
13009 < All |vim-variable|s must be prefixed by "v:". E.g. "version" doesn't | 13013 < All |vim-variable|s must be prefixed by "v:". E.g. "version" doesn't |