Mercurial > vim
comparison runtime/doc/eval.txt @ 7712:bce3b5ddb393 v7.4.1154
commit https://github.com/vim/vim/commit/520e1e41f35b063ede63b41738c82d6636e78c34
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 23 19:46:28 2016 +0100
patch 7.4.1154
Problem: No support for JSON.
Solution: Add jsonencode() and jsondecode(). Also add v:false, v:true,
v:null and v:none.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 23 Jan 2016 20:00:04 +0100 |
parents | 41768bcebc9b |
children | 5f6f35a3cb12 |
comparison
equal
deleted
inserted
replaced
7711:5fe266fb2a6e | 7712:bce3b5ddb393 |
---|---|
1 *eval.txt* For Vim version 7.4. Last change: 2016 Jan 21 | 1 *eval.txt* For Vim version 7.4. Last change: 2016 Jan 23 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
1407 :catch /.*/ | 1407 :catch /.*/ |
1408 : echo "caught" v:exception | 1408 : echo "caught" v:exception |
1409 :endtry | 1409 :endtry |
1410 < Output: "caught oops". | 1410 < Output: "caught oops". |
1411 | 1411 |
1412 *v:false* *false-variable* | |
1413 v:false A Number with value zero. Used to put "false" in JSON. See | |
1414 |jsonencode()|. | |
1415 | |
1412 *v:fcs_reason* *fcs_reason-variable* | 1416 *v:fcs_reason* *fcs_reason-variable* |
1413 v:fcs_reason The reason why the |FileChangedShell| event was triggered. | 1417 v:fcs_reason The reason why the |FileChangedShell| event was triggered. |
1414 Can be used in an autocommand to decide what to do and/or what | 1418 Can be used in an autocommand to decide what to do and/or what |
1415 to set v:fcs_choice to. Possible values: | 1419 to set v:fcs_choice to. Possible values: |
1416 deleted file no longer exists | 1420 deleted file no longer exists |
1539 | 1543 |
1540 *v:mouse_col* *mouse_col-variable* | 1544 *v:mouse_col* *mouse_col-variable* |
1541 v:mouse_col Column number for a mouse click obtained with |getchar()|. | 1545 v:mouse_col Column number for a mouse click obtained with |getchar()|. |
1542 This is the screen column number, like with |virtcol()|. The | 1546 This is the screen column number, like with |virtcol()|. The |
1543 value is zero when there was no mouse button click. | 1547 value is zero when there was no mouse button click. |
1548 | |
1549 *v:none* *none-variable* | |
1550 v:none An empty String. Used to put an empty item in JSON. See | |
1551 |jsonencode()|. | |
1552 | |
1553 *v:null* *null-variable* | |
1554 v:null An empty String. Used to put "null" in JSON. See | |
1555 |jsonencode()|. | |
1544 | 1556 |
1545 *v:oldfiles* *oldfiles-variable* | 1557 *v:oldfiles* *oldfiles-variable* |
1546 v:oldfiles List of file names that is loaded from the |viminfo| file on | 1558 v:oldfiles List of file names that is loaded from the |viminfo| file on |
1547 startup. These are the files that Vim remembers marks for. | 1559 startup. These are the files that Vim remembers marks for. |
1548 The length of the List is limited by the ' argument of the | 1560 The length of the List is limited by the ' argument of the |
1704 : throw "oops" | 1716 : throw "oops" |
1705 :catch /.*/ | 1717 :catch /.*/ |
1706 : echo "Exception from" v:throwpoint | 1718 : echo "Exception from" v:throwpoint |
1707 :endtry | 1719 :endtry |
1708 < Output: "Exception from test.vim, line 2" | 1720 < Output: "Exception from test.vim, line 2" |
1721 | |
1722 *v:true* *true-variable* | |
1723 v:true A Number with value one. Used to put "true" in JSON. See | |
1724 |jsonencode()|. | |
1709 | 1725 |
1710 *v:val* *val-variable* | 1726 *v:val* *val-variable* |
1711 v:val Value of the current item of a |List| or |Dictionary|. Only | 1727 v:val Value of the current item of a |List| or |Dictionary|. Only |
1712 valid while evaluating the expression used with |map()| and | 1728 valid while evaluating the expression used with |map()| and |
1713 |filter()|. Read-only. | 1729 |filter()|. Read-only. |
1911 invert( {expr}) Number bitwise invert | 1927 invert( {expr}) Number bitwise invert |
1912 isdirectory( {directory}) Number TRUE if {directory} is a directory | 1928 isdirectory( {directory}) Number TRUE if {directory} is a directory |
1913 islocked( {expr}) Number TRUE if {expr} is locked | 1929 islocked( {expr}) Number TRUE if {expr} is locked |
1914 items( {dict}) List key-value pairs in {dict} | 1930 items( {dict}) List key-value pairs in {dict} |
1915 join( {list} [, {sep}]) String join {list} items into one String | 1931 join( {list} [, {sep}]) String join {list} items into one String |
1932 jsondecode( {string}) any decode JSON | |
1933 jsonencode( {expr}) String encode JSON | |
1916 keys( {dict}) List keys in {dict} | 1934 keys( {dict}) List keys in {dict} |
1917 len( {expr}) Number the length of {expr} | 1935 len( {expr}) Number the length of {expr} |
1918 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} | 1936 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} |
1919 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number | 1937 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number |
1920 line( {expr}) Number line nr of cursor, last line or mark | 1938 line( {expr}) Number line nr of cursor, last line or mark |
4213 let lines = join(mylist, "\n") . "\n" | 4231 let lines = join(mylist, "\n") . "\n" |
4214 < String items are used as-is. |Lists| and |Dictionaries| are | 4232 < String items are used as-is. |Lists| and |Dictionaries| are |
4215 converted into a string like with |string()|. | 4233 converted into a string like with |string()|. |
4216 The opposite function is |split()|. | 4234 The opposite function is |split()|. |
4217 | 4235 |
4236 jsondecode({string}) *jsondecode()* | |
4237 TODO | |
4238 | |
4239 jsonencode({expr}) *jsonencode()* | |
4240 Encodode {expr} as JSON and return this as a string. | |
4241 The encoding is specified in: | |
4242 http://www.ietf.org/rfc/rfc4627.txt | |
4243 Vim values are converted as follows: | |
4244 Number decimal number | |
4245 Float floating point number | |
4246 String in double quotes (possibly null) | |
4247 Funcref nothing | |
4248 List as an array (possibly null); when | |
4249 used recursively: [] | |
4250 Dict as an object (possibly null); when | |
4251 used recursively: {} | |
4252 v:false "false" | |
4253 v:true "true" | |
4254 v:none nothing | |
4255 v:null "null" | |
4256 | |
4218 keys({dict}) *keys()* | 4257 keys({dict}) *keys()* |
4219 Return a |List| with all the keys of {dict}. The |List| is in | 4258 Return a |List| with all the keys of {dict}. The |List| is in |
4220 arbitrary order. | 4259 arbitrary order. |
4221 | 4260 |
4222 *len()* *E701* | 4261 *len()* *E701* |