Mercurial > vim
comparison runtime/doc/eval.txt @ 7742:5f6f35a3cb12
commit https://github.com/vim/vim/commit/705ada1aff27ecd9c47c690df817d043c2ceb5e2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 24 17:56:50 2016 +0100
Update a few runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Jan 2016 18:00:06 +0100 |
parents | bce3b5ddb393 |
children | 3a99194bd187 |
comparison
equal
deleted
inserted
replaced
7741:74b54a066bff | 7742:5f6f35a3cb12 |
---|---|
1 *eval.txt* For Vim version 7.4. Last change: 2016 Jan 23 | 1 *eval.txt* For Vim version 7.4. Last change: 2016 Jan 24 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
1410 < Output: "caught oops". | 1410 < Output: "caught oops". |
1411 | 1411 |
1412 *v:false* *false-variable* | 1412 *v:false* *false-variable* |
1413 v:false A Number with value zero. Used to put "false" in JSON. See | 1413 v:false A Number with value zero. Used to put "false" in JSON. See |
1414 |jsonencode()|. | 1414 |jsonencode()|. |
1415 When used as a string this evaluates to "false". > | |
1416 echo v:false | |
1417 < false ~ | |
1415 | 1418 |
1416 *v:fcs_reason* *fcs_reason-variable* | 1419 *v:fcs_reason* *fcs_reason-variable* |
1417 v:fcs_reason The reason why the |FileChangedShell| event was triggered. | 1420 v:fcs_reason The reason why the |FileChangedShell| event was triggered. |
1418 Can be used in an autocommand to decide what to do and/or what | 1421 Can be used in an autocommand to decide what to do and/or what |
1419 to set v:fcs_choice to. Possible values: | 1422 to set v:fcs_choice to. Possible values: |
1487 | 1490 |
1488 *v:hlsearch* *hlsearch-variable* | 1491 *v:hlsearch* *hlsearch-variable* |
1489 v:hlsearch Variable that indicates whether search highlighting is on. | 1492 v:hlsearch Variable that indicates whether search highlighting is on. |
1490 Setting it makes sense only if 'hlsearch' is enabled which | 1493 Setting it makes sense only if 'hlsearch' is enabled which |
1491 requires |+extra_search|. Setting this variable to zero acts | 1494 requires |+extra_search|. Setting this variable to zero acts |
1492 the like |:nohlsearch| command, setting it to one acts like > | 1495 like the |:nohlsearch| command, setting it to one acts like > |
1493 let &hlsearch = &hlsearch | 1496 let &hlsearch = &hlsearch |
1494 < Note that the value is restored when returning from a | 1497 < Note that the value is restored when returning from a |
1495 function. |function-search-undo|. | 1498 function. |function-search-undo|. |
1496 | 1499 |
1497 *v:insertmode* *insertmode-variable* | 1500 *v:insertmode* *insertmode-variable* |
1547 value is zero when there was no mouse button click. | 1550 value is zero when there was no mouse button click. |
1548 | 1551 |
1549 *v:none* *none-variable* | 1552 *v:none* *none-variable* |
1550 v:none An empty String. Used to put an empty item in JSON. See | 1553 v:none An empty String. Used to put an empty item in JSON. See |
1551 |jsonencode()|. | 1554 |jsonencode()|. |
1555 When used as a number this evaluates to zero. | |
1556 When used as a string this evaluates to "none". > | |
1557 echo v:none | |
1558 < none ~ | |
1552 | 1559 |
1553 *v:null* *null-variable* | 1560 *v:null* *null-variable* |
1554 v:null An empty String. Used to put "null" in JSON. See | 1561 v:null An empty String. Used to put "null" in JSON. See |
1555 |jsonencode()|. | 1562 |jsonencode()|. |
1563 When used as a number this evaluates to zero. | |
1564 When used as a string this evaluates to "null". > | |
1565 echo v:null | |
1566 < null ~ | |
1556 | 1567 |
1557 *v:oldfiles* *oldfiles-variable* | 1568 *v:oldfiles* *oldfiles-variable* |
1558 v:oldfiles List of file names that is loaded from the |viminfo| file on | 1569 v:oldfiles List of file names that is loaded from the |viminfo| file on |
1559 startup. These are the files that Vim remembers marks for. | 1570 startup. These are the files that Vim remembers marks for. |
1560 The length of the List is limited by the ' argument of the | 1571 The length of the List is limited by the ' argument of the |
1720 < Output: "Exception from test.vim, line 2" | 1731 < Output: "Exception from test.vim, line 2" |
1721 | 1732 |
1722 *v:true* *true-variable* | 1733 *v:true* *true-variable* |
1723 v:true A Number with value one. Used to put "true" in JSON. See | 1734 v:true A Number with value one. Used to put "true" in JSON. See |
1724 |jsonencode()|. | 1735 |jsonencode()|. |
1725 | 1736 When used as a string this evaluates to "true". > |
1737 echo v:true | |
1738 < true ~ | |
1726 *v:val* *val-variable* | 1739 *v:val* *val-variable* |
1727 v:val Value of the current item of a |List| or |Dictionary|. Only | 1740 v:val Value of the current item of a |List| or |Dictionary|. Only |
1728 valid while evaluating the expression used with |map()| and | 1741 valid while evaluating the expression used with |map()| and |
1729 |filter()|. Read-only. | 1742 |filter()|. Read-only. |
1730 | 1743 |
4232 < String items are used as-is. |Lists| and |Dictionaries| are | 4245 < String items are used as-is. |Lists| and |Dictionaries| are |
4233 converted into a string like with |string()|. | 4246 converted into a string like with |string()|. |
4234 The opposite function is |split()|. | 4247 The opposite function is |split()|. |
4235 | 4248 |
4236 jsondecode({string}) *jsondecode()* | 4249 jsondecode({string}) *jsondecode()* |
4237 TODO | 4250 This parses a JSON formatted string and returns the equivalent |
4251 in Vim values. See |jsonencode()| for the relation between | |
4252 JSON and Vim values. | |
4253 The decoding is permissive: | |
4254 - A trailing comma in an array and object is ignored. | |
4255 - An empty item in an array results in v:none. | |
4256 - When an object name is not a string it is converted to a | |
4257 string. E.g. the number 123 is used as the string "123". | |
4258 - More floating point numbers are recognized, e.g. "1." for | |
4259 "1.0". | |
4238 | 4260 |
4239 jsonencode({expr}) *jsonencode()* | 4261 jsonencode({expr}) *jsonencode()* |
4240 Encodode {expr} as JSON and return this as a string. | 4262 Encode {expr} as JSON and return this as a string. |
4241 The encoding is specified in: | 4263 The encoding is specified in: |
4242 http://www.ietf.org/rfc/rfc4627.txt | 4264 http://www.ietf.org/rfc/rfc4627.txt |
4243 Vim values are converted as follows: | 4265 Vim values are converted as follows: |
4244 Number decimal number | 4266 Number decimal number |
4245 Float floating point number | 4267 Float floating point number |
4246 String in double quotes (possibly null) | 4268 String in double quotes (possibly null) |
4247 Funcref nothing | 4269 Funcref not possible, error |
4248 List as an array (possibly null); when | 4270 List as an array (possibly null); when |
4249 used recursively: [] | 4271 used recursively: [] |
4250 Dict as an object (possibly null); when | 4272 Dict as an object (possibly null); when |
4251 used recursively: {} | 4273 used recursively: {} |
4252 v:false "false" | 4274 v:false "false" |
4253 v:true "true" | 4275 v:true "true" |
4254 v:none nothing | 4276 v:none nothing |
4255 v:null "null" | 4277 v:null "null" |
4278 Note that using v:none is permitted, although the JSON | |
4279 standard does not allow empty items. This can be useful for | |
4280 omitting items in an array: | |
4281 [0,,,,,5] ~ | |
4282 This is much more efficient than: | |
4283 [0,null,null,null,null,5] ~ | |
4284 But a strict JSON parser will not accept it. | |
4256 | 4285 |
4257 keys({dict}) *keys()* | 4286 keys({dict}) *keys()* |
4258 Return a |List| with all the keys of {dict}. The |List| is in | 4287 Return a |List| with all the keys of {dict}. The |List| is in |
4259 arbitrary order. | 4288 arbitrary order. |
4260 | 4289 |
6613 String: 1 | 6642 String: 1 |
6614 Funcref: 2 | 6643 Funcref: 2 |
6615 List: 3 | 6644 List: 3 |
6616 Dictionary: 4 | 6645 Dictionary: 4 |
6617 Float: 5 | 6646 Float: 5 |
6647 Boolean: 6 (v:false and v:true) | |
6648 None 7 (v:null and v:none) | |
6618 To avoid the magic numbers it should be used this way: > | 6649 To avoid the magic numbers it should be used this way: > |
6619 :if type(myvar) == type(0) | 6650 :if type(myvar) == type(0) |
6620 :if type(myvar) == type("") | 6651 :if type(myvar) == type("") |
6621 :if type(myvar) == type(function("tr")) | 6652 :if type(myvar) == type(function("tr")) |
6622 :if type(myvar) == type([]) | 6653 :if type(myvar) == type([]) |
6623 :if type(myvar) == type({}) | 6654 :if type(myvar) == type({}) |
6624 :if type(myvar) == type(0.0) | 6655 :if type(myvar) == type(0.0) |
6656 :if type(myvar) == type(v:false) | |
6657 :if type(myvar) == type(v:none | |
6625 | 6658 |
6626 undofile({name}) *undofile()* | 6659 undofile({name}) *undofile()* |
6627 Return the name of the undo file that would be used for a file | 6660 Return the name of the undo file that would be used for a file |
6628 with name {name} when writing. This uses the 'undodir' | 6661 with name {name} when writing. This uses the 'undodir' |
6629 option, finding directories that exist. It does not check if | 6662 option, finding directories that exist. It does not check if |