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
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1412,6 +1412,9 @@ v:exception The value of the exception most recently caught and not
14121412 *v:false* *false-variable*
14131413v:false A Number with value zero. Used to put "false" in JSON. See
14141414 | jsonencode() | .
1415+ When used as a string this evaluates to "false". >
1416+ echo v:false
1417+ < false ~
14151418
14161419 *v:fcs_reason* *fcs_reason-variable*
14171420v:fcs_reason The reason why the | FileChangedShell | event was triggered.
@@ -1489,7 +1492,7 @@ v:foldstart Used for 'foldtext': first line of closed fold.
14891492v:hlsearch Variable that indicates whether search highlighting is on.
14901493 Setting it makes sense only if 'hlsearch' is enabled which
14911494 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 >
14931496 let &hlsearch = &hlsearch
14941497< Note that the value is restored when returning from a
14951498 function. | function-search-undo | .
@@ -1549,10 +1552,18 @@ v:mouse_col Column number for a mouse click obtained with |getchar()|.
15491552 *v:none* *none-variable*
15501553v:none An empty String. Used to put an empty item in JSON. See
15511554 | 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 ~
15521559
15531560 *v:null* *null-variable*
15541561v:null An empty String. Used to put "null" in JSON. See
15551562 | 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 ~
15561567
15571568 *v:oldfiles* *oldfiles-variable*
15581569v:oldfiles List of file names that is loaded from the | viminfo | file on
@@ -1722,7 +1733,9 @@ v:throwpoint The point where the exception most recently caught and not
17221733 *v:true* *true-variable*
17231734v:true A Number with value one. Used to put "true" in JSON. See
17241735 | jsonencode() | .
1725-
1736+ When used as a string this evaluates to "true". >
1737+ echo v:true
1738+ < true ~
17261739 *v:val* *val-variable*
17271740v:val Value of the current item of a | List | or | Dictionary | . Only
17281741 valid while evaluating the expression used with | map() | and
@@ -4234,17 +4247,26 @@ join({list} [, {sep}]) *join()*
42344247 The opposite function is | split() | .
42354248
42364249jsondecode({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".
42384260
42394261jsonencode({expr} ) *jsonencode()*
4240- Encodode {expr} as JSON and return this as a string.
4262+ Encode {expr} as JSON and return this as a string.
42414263 The encoding is specified in:
42424264 http://www.ietf.org/rfc/rfc4627.txt
42434265 Vim values are converted as follows:
42444266 Number decimal number
42454267 Float floating point number
42464268 String in double quotes (possibly null)
4247- Funcref nothing
4269+ Funcref not possible, error
42484270 List as an array (possibly null); when
42494271 used recursively: []
42504272 Dict as an object (possibly null); when
@@ -4253,6 +4275,13 @@ jsonencode({expr}) *jsonencode()*
42534275 v:true "true"
42544276 v:none nothing
42554277 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.
42564285
42574286keys({dict} ) *keys()*
42584287 Return a | List | with all the keys of {dict} . The | List | is in
@@ -6615,13 +6644,17 @@ type({expr}) The result is a Number, depending on the type of {expr}:
66156644 List: 3
66166645 Dictionary: 4
66176646 Float: 5
6647+ Boolean: 6 (v:false and v:true)
6648+ None 7 (v:null and v:none)
66186649 To avoid the magic numbers it should be used this way: >
66196650 :if type(myvar) == type(0)
66206651 :if type(myvar) == type("")
66216652 :if type(myvar) == type(function("tr"))
66226653 :if type(myvar) == type([])
66236654 :if type(myvar) == type({})
66246655 :if type(myvar) == type(0.0)
6656+ :if type(myvar) == type(v:false)
6657+ :if type(myvar) == type(v:none
66256658
66266659 undofile({name} ) *undofile()*
66276660 Return the name of the undo file that would be used for a file
0 commit comments