comparison runtime/doc/eval.txt @ 15512:f0f06837a699

Update runtime files. commit https://github.com/vim/vim/commit/d09091d4955c5f41de69928f2db85611ed54ed23 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 17 16:07:22 2019 +0100 Update runtime files.
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Jan 2019 16:15:08 +0100
parents e1de20a47fa9
children 4af72c724093
comparison
equal deleted inserted replaced
15511:f41122780189 15512:f0f06837a699
1 *eval.txt* For Vim version 8.1. Last change: 2019 Jan 15 1 *eval.txt* For Vim version 8.1. Last change: 2019 Jan 17
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
105 < 64 ~ 105 < 64 ~
106 106
107 To avoid a leading zero to cause octal conversion, or for using a different 107 To avoid a leading zero to cause octal conversion, or for using a different
108 base, use |str2nr()|. 108 base, use |str2nr()|.
109 109
110 *TRUE* *FALSE* 110 *TRUE* *FALSE* *Boolean*
111 For boolean operators Numbers are used. Zero is FALSE, non-zero is TRUE. 111 For boolean operators Numbers are used. Zero is FALSE, non-zero is TRUE.
112 You can also use |v:false| and |v:true|. When TRUE is returned from a 112 You can also use |v:false| and |v:true|. When TRUE is returned from a
113 function it is the Number one, FALSE is the number zero. 113 function it is the Number one, FALSE is the number zero.
114 114
115 Note that in the command: > 115 Note that in the command: >
129 Note that " " and "0" are also non-empty strings, thus considered to be TRUE. 129 Note that " " and "0" are also non-empty strings, thus considered to be TRUE.
130 A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE. 130 A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE.
131 131
132 *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* *E913* 132 *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910* *E913*
133 *E974* *E975* *E976* 133 *E974* *E975* *E976*
134 List, Dictionary, Funcref, Job, Channel and Blob types are not automatically 134 |List|, |Dictionary|, |Funcref|, |Job|, |Channel| and |Blob| types are not
135 converted. 135 automatically converted.
136 136
137 *E805* *E806* *E808* 137 *E805* *E806* *E808*
138 When mixing Number and Float the Number is converted to Float. Otherwise 138 When mixing Number and Float the Number is converted to Float. Otherwise
139 there is no automatic conversion of Float. You can use str2float() for String 139 there is no automatic conversion of Float. You can use str2float() for String
140 to Float, printf() for Float to String and float2nr() for Float to Number. 140 to Float, printf() for Float to String and float2nr() for Float to Number.
671 Part of a blob ~ 671 Part of a blob ~
672 672
673 A part of the Blob can be obtained by specifying the first and last index, 673 A part of the Blob can be obtained by specifying the first and last index,
674 separated by a colon in square brackets: > 674 separated by a colon in square brackets: >
675 :let myblob = 0z00112233 675 :let myblob = 0z00112233
676 :let shortblob = myblob[1:2] " get 0z1122
676 :let shortblob = myblob[2:-1] " get 0z2233 677 :let shortblob = myblob[2:-1] " get 0z2233
677 678
678 Omitting the first index is similar to zero. Omitting the last index is 679 Omitting the first index is similar to zero. Omitting the last index is
679 similar to -1. > 680 similar to -1. >
680 :let endblob = myblob[2:] " from item 2 to the end: 0z2233 681 :let endblob = myblob[2:] " from item 2 to the end: 0z2233
681 :let shortblob = myblob[2:2] " Blob with one byte: 0z22 682 :let shortblob = myblob[2:2] " Blob with one byte: 0z22
682 :let otherblob = myblob[:] " make a copy of the Blob 683 :let otherblob = myblob[:] " make a copy of the Blob
683 684
684 If the first index is beyond the last byte of the Blob or the second byte is 685 If the first index is beyond the last byte of the Blob or the second index is
685 before the first byte, the result is an empty list. There is no error 686 before the first byte, the result is an empty list. There is no error
686 message. 687 message.
687 688
688 If the second index is equal to or greater than the length of the list the 689 If the second index is equal to or greater than the length of the list the
689 length minus one is used: > 690 length minus one is used: >
698 When the index is just one beyond the end of the Blob, it is appended. Any 699 When the index is just one beyond the end of the Blob, it is appended. Any
699 higher index is an error. 700 higher index is an error.
700 701
701 To change a sequence of bytes the [:] notation can be used: > 702 To change a sequence of bytes the [:] notation can be used: >
702 let blob[1:3] = 0z445566 703 let blob[1:3] = 0z445566
703 The length of the replaced bytes much be exactly the same as the value 704 The length of the replaced bytes must be exactly the same as the value
704 provided. *E972* 705 provided. *E972*
705 706
706 To change part of a blob you can specify the first and last byte to be 707 To change part of a blob you can specify the first and last byte to be
707 modified. The value must at least have the number of bytes in the range: > 708 modified. The value must have the same number of bytes in the range: >
708 :let blob[3:5] = [3, 4, 5] 709 :let blob[3:5] = 0z334455
709 710
710 You can also use the functions |add()|, |remove()| and |insert()|. 711 You can also use the functions |add()|, |remove()| and |insert()|.
711 712
712 713
713 Blob identity ~ 714 Blob identity ~
732 :echo blob == blob3 733 :echo blob == blob3
733 < 1 > 734 < 1 >
734 :echo blob is blob3 735 :echo blob is blob3
735 < 0 736 < 0
736 737
737 Making a copy of a list is done with the |copy()| function. Using [:] also 738 Making a copy of a Blob is done with the |copy()| function. Using [:] also
738 works, as explained above. 739 works, as explained above.
739 740
740 741
741 1.6 More about variables ~ 742 1.6 More about variables ~
742 *more-variables* 743 *more-variables*
791 792
792 expr5 is expr5 same |List| instance 793 expr5 is expr5 same |List| instance
793 expr5 isnot expr5 different |List| instance 794 expr5 isnot expr5 different |List| instance
794 795
795 |expr5| expr6 796 |expr5| expr6
796 expr6 + expr6 .. number addition or list concatenation 797 expr6 + expr6 .. number addition, list or blob concatenation
797 expr6 - expr6 .. number subtraction 798 expr6 - expr6 .. number subtraction
798 expr6 . expr6 .. string concatenation 799 expr6 . expr6 .. string concatenation
799 800
800 |expr6| expr7 801 |expr6| expr7
801 expr7 * expr7 .. number multiplication 802 expr7 * expr7 .. number multiplication
1141 1142
1142 If expr8 is a |Blob| this results in a new |Blob| with the bytes in the 1143 If expr8 is a |Blob| this results in a new |Blob| with the bytes in the
1143 indexes expr1a and expr1b, inclusive. Examples: > 1144 indexes expr1a and expr1b, inclusive. Examples: >
1144 :let b = 0zDEADBEEF 1145 :let b = 0zDEADBEEF
1145 :let bs = b[1:2] " 0zADBE 1146 :let bs = b[1:2] " 0zADBE
1146 :let bs = b[] " copy ov 0zDEADBEEF 1147 :let bs = b[:] " copy of 0zDEADBEEF
1147 1148
1148 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an 1149 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an
1149 error. 1150 error.
1150 1151
1151 Watch out for confusion between a namespace and a variable followed by a colon 1152 Watch out for confusion between a namespace and a variable followed by a colon
1869 *v:mouse_col* *mouse_col-variable* 1870 *v:mouse_col* *mouse_col-variable*
1870 v:mouse_col Column number for a mouse click obtained with |getchar()|. 1871 v:mouse_col Column number for a mouse click obtained with |getchar()|.
1871 This is the screen column number, like with |virtcol()|. The 1872 This is the screen column number, like with |virtcol()|. The
1872 value is zero when there was no mouse button click. 1873 value is zero when there was no mouse button click.
1873 1874
1874 *v:none* *none-variable* 1875 *v:none* *none-variable* *None*
1875 v:none An empty String. Used to put an empty item in JSON. See 1876 v:none An empty String. Used to put an empty item in JSON. See
1876 |json_encode()|. 1877 |json_encode()|.
1877 When used as a number this evaluates to zero. 1878 When used as a number this evaluates to zero.
1878 When used as a string this evaluates to "v:none". > 1879 When used as a string this evaluates to "v:none". >
1879 echo v:none 1880 echo v:none
2026 another Vim open the file and jump to the right place. For 2027 another Vim open the file and jump to the right place. For
2027 example, when jumping to a tag the value is ":tag tagname\r". 2028 example, when jumping to a tag the value is ":tag tagname\r".
2028 For ":edit +cmd file" the value is ":cmd\r". 2029 For ":edit +cmd file" the value is ":cmd\r".
2029 2030
2030 *v:t_TYPE* *v:t_bool* *t_bool-variable* 2031 *v:t_TYPE* *v:t_bool* *t_bool-variable*
2031 v:t_bool Value of Boolean type. Read-only. See: |type()| 2032 v:t_bool Value of |Boolean| type. Read-only. See: |type()|
2032 *v:t_channel* *t_channel-variable* 2033 *v:t_channel* *t_channel-variable*
2033 v:t_channel Value of Channel type. Read-only. See: |type()| 2034 v:t_channel Value of |Channel| type. Read-only. See: |type()|
2034 *v:t_dict* *t_dict-variable* 2035 *v:t_dict* *t_dict-variable*
2035 v:t_dict Value of Dictionary type. Read-only. See: |type()| 2036 v:t_dict Value of |Dictionary| type. Read-only. See: |type()|
2036 *v:t_float* *t_float-variable* 2037 *v:t_float* *t_float-variable*
2037 v:t_float Value of Float type. Read-only. See: |type()| 2038 v:t_float Value of |Float| type. Read-only. See: |type()|
2038 *v:t_func* *t_func-variable* 2039 *v:t_func* *t_func-variable*
2039 v:t_func Value of Funcref type. Read-only. See: |type()| 2040 v:t_func Value of |Funcref| type. Read-only. See: |type()|
2040 *v:t_job* *t_job-variable* 2041 *v:t_job* *t_job-variable*
2041 v:t_job Value of Job type. Read-only. See: |type()| 2042 v:t_job Value of |Job| type. Read-only. See: |type()|
2042 *v:t_list* *t_list-variable* 2043 *v:t_list* *t_list-variable*
2043 v:t_list Value of List type. Read-only. See: |type()| 2044 v:t_list Value of |List| type. Read-only. See: |type()|
2044 *v:t_none* *t_none-variable* 2045 *v:t_none* *t_none-variable*
2045 v:t_none Value of None type. Read-only. See: |type()| 2046 v:t_none Value of |None| type. Read-only. See: |type()|
2046 *v:t_number* *t_number-variable* 2047 *v:t_number* *t_number-variable*
2047 v:t_number Value of Number type. Read-only. See: |type()| 2048 v:t_number Value of |Number| type. Read-only. See: |type()|
2048 *v:t_string* *t_string-variable* 2049 *v:t_string* *t_string-variable*
2049 v:t_string Value of String type. Read-only. See: |type()| 2050 v:t_string Value of |String| type. Read-only. See: |type()|
2050 *v:t_blob* *t_blob-variable* 2051 *v:t_blob* *t_blob-variable*
2051 v:t_blob Value of Blob type. Read-only. See: |type()| 2052 v:t_blob Value of |Blob| type. Read-only. See: |type()|
2052 2053
2053 *v:termresponse* *termresponse-variable* 2054 *v:termresponse* *termresponse-variable*
2054 v:termresponse The escape sequence returned by the terminal for the |t_RV| 2055 v:termresponse The escape sequence returned by the terminal for the |t_RV|
2055 termcap entry. It is set when Vim receives an escape sequence 2056 termcap entry. It is set when Vim receives an escape sequence
2056 that starts with ESC [ or CSI and ends in a 'c', with only 2057 that starts with ESC [ or CSI and ends in a 'c', with only
3340 there is nothing more to read (channel was closed). 3341 there is nothing more to read (channel was closed).
3341 See |channel-more|. 3342 See |channel-more|.
3342 {only available when compiled with the |+channel| feature} 3343 {only available when compiled with the |+channel| feature}
3343 3344
3344 ch_readblob({handle} [, {options}]) *ch_readblob()* 3345 ch_readblob({handle} [, {options}]) *ch_readblob()*
3345 Like ch_read() but reads binary data and returns a Blob. 3346 Like ch_read() but reads binary data and returns a |Blob|.
3346 See |channel-more|. 3347 See |channel-more|.
3347 {only available when compiled with the |+channel| feature} 3348 {only available when compiled with the |+channel| feature}
3348 3349
3349 ch_readraw({handle} [, {options}]) *ch_readraw()* 3350 ch_readraw({handle} [, {options}]) *ch_readraw()*
3350 Like ch_read() but for a JS and JSON channel does not decode 3351 Like ch_read() but for a JS and JSON channel does not decode
3361 {handle} can be a Channel or a Job that has a Channel. 3362 {handle} can be a Channel or a Job that has a Channel.
3362 3363
3363 {only available when compiled with the |+channel| feature} 3364 {only available when compiled with the |+channel| feature}
3364 3365
3365 ch_sendraw({handle}, {expr} [, {options}]) *ch_sendraw()* 3366 ch_sendraw({handle}, {expr} [, {options}]) *ch_sendraw()*
3366 Send string or Blob {expr} over {handle}. 3367 Send |String| or |Blob| {expr} over {handle}.
3367 Works like |ch_sendexpr()|, but does not encode the request or 3368 Works like |ch_sendexpr()|, but does not encode the request or
3368 decode the response. The caller is responsible for the 3369 decode the response. The caller is responsible for the
3369 correct contents. Also does not add a newline for a channel 3370 correct contents. Also does not add a newline for a channel
3370 in NL mode, the caller must do that. The NL in the response 3371 in NL mode, the caller must do that. The NL in the response
3371 is removed. 3372 is removed.
3786 - A |String| is empty when its length is zero. 3787 - A |String| is empty when its length is zero.
3787 - A |Number| and |Float| are empty when their value is zero. 3788 - A |Number| and |Float| are empty when their value is zero.
3788 - |v:false|, |v:none| and |v:null| are empty, |v:true| is not. 3789 - |v:false|, |v:none| and |v:null| are empty, |v:true| is not.
3789 - A |Job| is empty when it failed to start. 3790 - A |Job| is empty when it failed to start.
3790 - A |Channel| is empty when it is closed. 3791 - A |Channel| is empty when it is closed.
3791 - A Blob is empty when its length is zero. 3792 - A |Blob| is empty when its length is zero.
3792 3793
3793 For a long |List| this is much faster than comparing the 3794 For a long |List| this is much faster than comparing the
3794 length with zero. 3795 length with zero.
3795 3796
3796 escape({string}, {chars}) *escape()* 3797 escape({string}, {chars}) *escape()*
5881 in Vim values. See |json_encode()| for the relation between 5882 in Vim values. See |json_encode()| for the relation between
5882 JSON and Vim values. 5883 JSON and Vim values.
5883 The decoding is permissive: 5884 The decoding is permissive:
5884 - A trailing comma in an array and object is ignored, e.g. 5885 - A trailing comma in an array and object is ignored, e.g.
5885 "[1, 2, ]" is the same as "[1, 2]". 5886 "[1, 2, ]" is the same as "[1, 2]".
5887 - Integer keys are accepted in objects, e.g. {1:2} is the
5888 same as {'1':2}.
5886 - More floating point numbers are recognized, e.g. "1." for 5889 - More floating point numbers are recognized, e.g. "1." for
5887 "1.0", or "001.2" for "1.2". Special floating point values 5890 "1.0", or "001.2" for "1.2". Special floating point values
5888 "Infinity", "-Infinity" and "NaN" (capitalization ignored) 5891 "Infinity", "-Infinity" and "NaN" (capitalization ignored)
5889 are accepted. 5892 are accepted.
5890 - Leading zeroes in integer numbers are ignored, e.g. "012" 5893 - Leading zeroes in integer numbers are ignored, e.g. "012"
5909 json_encode({expr}) *json_encode()* 5912 json_encode({expr}) *json_encode()*
5910 Encode {expr} as JSON and return this as a string. 5913 Encode {expr} as JSON and return this as a string.
5911 The encoding is specified in: 5914 The encoding is specified in:
5912 https://tools.ietf.org/html/rfc7159.html 5915 https://tools.ietf.org/html/rfc7159.html
5913 Vim values are converted as follows: 5916 Vim values are converted as follows:
5914 Number decimal number 5917 |Number| decimal number
5915 Float floating point number 5918 |Float| floating point number
5916 Float nan "NaN" 5919 Float nan "NaN"
5917 Float inf "Infinity" 5920 Float inf "Infinity"
5918 Float -inf "-Infinity" 5921 Float -inf "-Infinity"
5919 String in double quotes (possibly null) 5922 |String| in double quotes (possibly null)
5920 Funcref not possible, error 5923 |Funcref| not possible, error
5921 List as an array (possibly null); when 5924 |List| as an array (possibly null); when
5922 used recursively: [] 5925 used recursively: []
5923 Dict as an object (possibly null); when 5926 |Dict| as an object (possibly null); when
5924 used recursively: {} 5927 used recursively: {}
5925 Blob as an array of the individual bytes 5928 |Blob| as an array of the individual bytes
5926 v:false "false" 5929 v:false "false"
5927 v:true "true" 5930 v:true "true"
5928 v:none "null" 5931 v:none "null"
5929 v:null "null" 5932 v:null "null"
5930 Note that NaN and Infinity are passed on as values. This is 5933 Note that NaN and Infinity are passed on as values. This is
5939 len({expr}) The result is a Number, which is the length of the argument. 5942 len({expr}) The result is a Number, which is the length of the argument.
5940 When {expr} is a String or a Number the length in bytes is 5943 When {expr} is a String or a Number the length in bytes is
5941 used, as with |strlen()|. 5944 used, as with |strlen()|.
5942 When {expr} is a |List| the number of items in the |List| is 5945 When {expr} is a |List| the number of items in the |List| is
5943 returned. 5946 returned.
5947 When {expr} is a |Blob| the number of bytes is returned.
5944 When {expr} is a |Dictionary| the number of entries in the 5948 When {expr} is a |Dictionary| the number of entries in the
5945 |Dictionary| is returned. 5949 |Dictionary| is returned.
5946 Otherwise an error is given. 5950 Otherwise an error is given.
5947 5951
5948 *libcall()* *E364* *E368* 5952 *libcall()* *E364* *E368*
10245 smartindent Compiled with 'smartindent' support. 10249 smartindent Compiled with 'smartindent' support.
10246 spell Compiled with spell checking support |spell|. 10250 spell Compiled with spell checking support |spell|.
10247 startuptime Compiled with |--startuptime| support. 10251 startuptime Compiled with |--startuptime| support.
10248 statusline Compiled with support for 'statusline', 'rulerformat' 10252 statusline Compiled with support for 'statusline', 'rulerformat'
10249 and special formats of 'titlestring' and 'iconstring'. 10253 and special formats of 'titlestring' and 'iconstring'.
10250 sun_workshop Compiled with support for Sun |workshop|. 10254 sun_workshop Support for Sun |workshop| has been removed.
10251 syntax Compiled with syntax highlighting support |syntax|. 10255 syntax Compiled with syntax highlighting support |syntax|.
10252 syntax_items There are active syntax highlighting items for the 10256 syntax_items There are active syntax highlighting items for the
10253 current buffer. 10257 current buffer.
10254 system Compiled to use system() instead of fork()/exec(). 10258 system Compiled to use system() instead of fork()/exec().
10255 tag_binary Compiled with binary searching in tags files 10259 tag_binary Compiled with binary searching in tags files