comparison runtime/doc/eval.txt @ 7782:3a99194bd187 v7.4.1188

commit https://github.com/vim/vim/commit/009d84a34f3678ec93921bee3bc05be2fd606264 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 28 14:12:00 2016 +0100 patch 7.4.1188 Problem: Using older JSON standard. Solution: Update the link. Adjust the text a bit.
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Jan 2016 14:15:04 +0100
parents 5f6f35a3cb12
children 192ae655ac91
comparison
equal deleted inserted replaced
7781:44dda9870e07 7782:3a99194bd187
1 *eval.txt* For Vim version 7.4. Last change: 2016 Jan 24 1 *eval.txt* For Vim version 7.4. Last change: 2016 Jan 28
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
2840 2840
2841 empty({expr}) *empty()* 2841 empty({expr}) *empty()*
2842 Return the Number 1 if {expr} is empty, zero otherwise. 2842 Return the Number 1 if {expr} is empty, zero otherwise.
2843 A |List| or |Dictionary| is empty when it does not have any 2843 A |List| or |Dictionary| is empty when it does not have any
2844 items. A Number is empty when its value is zero. 2844 items. A Number is empty when its value is zero.
2845 |v:false|, |v:none| and |v:null| are empty, |v:true| is not.
2845 For a long |List| this is much faster than comparing the 2846 For a long |List| this is much faster than comparing the
2846 length with zero. 2847 length with zero.
2847 2848
2848 escape({string}, {chars}) *escape()* 2849 escape({string}, {chars}) *escape()*
2849 Escape the characters in {chars} that occur in {string} with a 2850 Escape the characters in {chars} that occur in {string} with a
4250 This parses a JSON formatted string and returns the equivalent 4251 This parses a JSON formatted string and returns the equivalent
4251 in Vim values. See |jsonencode()| for the relation between 4252 in Vim values. See |jsonencode()| for the relation between
4252 JSON and Vim values. 4253 JSON and Vim values.
4253 The decoding is permissive: 4254 The decoding is permissive:
4254 - A trailing comma in an array and object is ignored. 4255 - A trailing comma in an array and object is ignored.
4255 - An empty item in an array results in v:none. 4256 - An empty item in an array, two commas with nothing or white
4256 - When an object name is not a string it is converted to a 4257 space in between, results in v:none.
4257 string. E.g. the number 123 is used as the string "123". 4258 - When an object member name is not a string it is converted
4259 to a string. E.g. the number 123 is used as the string
4260 "123".
4258 - More floating point numbers are recognized, e.g. "1." for 4261 - More floating point numbers are recognized, e.g. "1." for
4259 "1.0". 4262 "1.0".
4263 The result must be a valid Vim type:
4264 - An empty object member name is not allowed.
4265 - Duplicate object member names are not allowed.
4260 4266
4261 jsonencode({expr}) *jsonencode()* 4267 jsonencode({expr}) *jsonencode()*
4262 Encode {expr} as JSON and return this as a string. 4268 Encode {expr} as JSON and return this as a string.
4263 The encoding is specified in: 4269 The encoding is specified in:
4264 http://www.ietf.org/rfc/rfc4627.txt 4270 https://tools.ietf.org/html/rfc7159.html
4265 Vim values are converted as follows: 4271 Vim values are converted as follows:
4266 Number decimal number 4272 Number decimal number
4267 Float floating point number 4273 Float floating point number
4268 String in double quotes (possibly null) 4274 String in double quotes (possibly null)
4269 Funcref not possible, error 4275 Funcref not possible, error
5887 5893
5888 5894
5889 shiftwidth() *shiftwidth()* 5895 shiftwidth() *shiftwidth()*
5890 Returns the effective value of 'shiftwidth'. This is the 5896 Returns the effective value of 'shiftwidth'. This is the
5891 'shiftwidth' value unless it is zero, in which case it is the 5897 'shiftwidth' value unless it is zero, in which case it is the
5892 'tabstop' value. To be backwards compatible in indent 5898 'tabstop' value. This function was introduced with patch
5893 plugins, use this: > 5899 7.3.694 in 2012, everybody should have it by now.
5894 if exists('*shiftwidth')
5895 func s:sw()
5896 return shiftwidth()
5897 endfunc
5898 else
5899 func s:sw()
5900 return &sw
5901 endfunc
5902 endif
5903 < And then use s:sw() instead of &sw.
5904 5900
5905 5901
5906 simplify({filename}) *simplify()* 5902 simplify({filename}) *simplify()*
5907 Simplify the file name as much as possible without changing 5903 Simplify the file name as much as possible without changing
5908 the meaning. Shortcuts (on MS-Windows) or symbolic links (on 5904 the meaning. Shortcuts (on MS-Windows) or symbolic links (on