1- *eval.txt* For Vim version 7.4. Last change: 2016 Jul 16
1+ *eval.txt* For Vim version 7.4. Last change: 2016 Jul 22
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1535,7 +1535,7 @@ v:false A Number with value zero. Used to put "false" in JSON. See
15351535 echo v:false
15361536< v:false ~
15371537 That is so that eval() can parse the string back to the same
1538- value.
1538+ value. Read-only.
15391539
15401540 *v:fcs_reason* *fcs_reason-variable*
15411541v:fcs_reason The reason why the | FileChangedShell | event was triggered.
@@ -1682,7 +1682,7 @@ v:none An empty String. Used to put an empty item in JSON. See
16821682 echo v:none
16831683< v:none ~
16841684 That is so that eval() can parse the string back to the same
1685- value.
1685+ value. Read-only.
16861686
16871687 *v:null* *null-variable*
16881688v:null An empty String. Used to put "null" in JSON. See
@@ -1692,7 +1692,7 @@ v:null An empty String. Used to put "null" in JSON. See
16921692 echo v:null
16931693< v:null ~
16941694 That is so that eval() can parse the string back to the same
1695- value.
1695+ value. Read-only.
16961696
16971697 *v:oldfiles* *oldfiles-variable*
16981698v:oldfiles List of file names that is loaded from the | viminfo | file on
@@ -1890,7 +1890,7 @@ v:true A Number with value one. Used to put "true" in JSON. See
18901890 echo v:true
18911891< v:true ~
18921892 That is so that eval() can parse the string back to the same
1893- value.
1893+ value. Read-only.
18941894 *v:val* *val-variable*
18951895v:val Value of the current item of a | List | or | Dictionary | . Only
18961896 valid while evaluating the expression used with | map() | and
@@ -7144,16 +7144,24 @@ substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
71447144 unmodified.
71457145
71467146 Example: >
7147- :let &path = substitute(&path, ",\\=[^,]*$", "", "")
7147+ :let &path = substitute(&path, ",\\=[^,]*$", "", "")
71487148< This removes the last component of the 'path' option. >
7149- :echo substitute("testing", ".*", "\\U\\0", "")
7149+ :echo substitute("testing", ".*", "\\U\\0", "")
71507150< results in "TESTING".
71517151
71527152 When {sub} starts with "\=", the remainder is interpreted as
71537153 an expression. See | sub-replace-expression | . Example: >
7154- :echo substitute(s, '%\(\x\x\)',
7154+ :echo substitute(s, '%\(\x\x\)',
71557155 \ '\=nr2char("0x" . submatch(1))', 'g')
71567156
7157+ < When {sub} is a Funcref that function is called, with one
7158+ optional argument. Example: >
7159+ :echo substitute(s, '%\(\x\x\)', SubNr, 'g')
7160+ < The optional argument is a list which contains the whole
7161+ matched string and up to nine submatches,like what
7162+ | submatch() | returns. Example: >
7163+ :echo substitute(s, '\(\x\x\)', {m -> '0x' . m[1]}, 'g')
7164+
71577165 synID({lnum} , {col} , {trans} ) *synID()*
71587166 The result is a Number, which is the syntax ID at the position
71597167 {lnum} and {col} in the current window.
@@ -7546,18 +7554,20 @@ trunc({expr}) *trunc()*
75467554 {only available when compiled with the | +float | feature}
75477555
75487556 *type()*
7549- type({expr} ) The result is a Number, depending on the type of {expr} :
7550- Number: 0
7551- String: 1
7552- Funcref: 2
7553- List: 3
7554- Dictionary: 4
7555- Float: 5
7556- Boolean: 6 (v:false and v:true)
7557- None 7 (v:null and v:none)
7558- Job 8
7559- Channel 9
7560- To avoid the magic numbers it should be used this way: >
7557+ type({expr} ) The result is a Number representing the type of {expr} .
7558+ Instead of using the number directly, it is better to use the
7559+ v:t_ variable that has the value:
7560+ Number: 0 | v:t_number |
7561+ String: 1 | v:t_string |
7562+ Funcref: 2 | v:t_func |
7563+ List: 3 | v:t_list |
7564+ Dictionary: 4 | v:t_dict |
7565+ Float: 5 | v:t_float |
7566+ Boolean: 6 | v:t_bool | (v:false and v:true)
7567+ None 7 | v:t_none | (v:null and v:none)
7568+ Job 8 | v:t_job |
7569+ Channel 9 | v:t_channel |
7570+ For backward compatibility, this method can be used: >
75617571 :if type(myvar) == type(0)
75627572 :if type(myvar) == type("")
75637573 :if type(myvar) == type(function("tr"))
@@ -7566,6 +7576,8 @@ type({expr}) The result is a Number, depending on the type of {expr}:
75667576 :if type(myvar) == type(0.0)
75677577 :if type(myvar) == type(v:false)
75687578 :if type(myvar) == type(v:none)
7579+ < To check if the v:t_ variables exist use this: >
7580+ :if exists('v:t_number')
75697581
75707582 undofile({name} ) *undofile()*
75717583 Return the name of the undo file that would be used for a file
0 commit comments