Diff to HTML by rtfpessoa

Files changed (12) hide show
  1. runtime/doc/builtin.txt +148 -80
  2. runtime/doc/change.txt +6 -1
  3. runtime/doc/eval.txt +292 -60
  4. runtime/doc/index.txt +3 -1
  5. runtime/doc/pattern.txt +2 -1
  6. runtime/doc/syntax.txt +7 -7
  7. runtime/doc/testing.txt +6 -1
  8. runtime/doc/usr_05.txt +28 -3
  9. runtime/doc/usr_41.txt +45 -3
  10. runtime/doc/usr_52.txt +6 -6
  11. runtime/doc/version9.txt +13 -2
  12. runtime/doc/vim9.txt +38 -6
runtime/doc/builtin.txt CHANGED
@@ -1,4 +1,4 @@
1
- *builtin.txt* For Vim version 9.1. Last change: 2025 Mar 16
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -207,7 +207,7 @@ foldclosedend({lnum}) Number last line of fold at {lnum} if closed
207
  foldlevel({lnum}) Number fold level at {lnum}
208
  foldtext() String line displayed for closed fold
209
  foldtextresult({lnum}) String text for closed fold at {lnum}
210
- foreach({expr1}, {expr2}) List/Dict/Blob/String
211
  for each item in {expr1} call {expr2}
212
  foreground() Number bring the Vim window to the foreground
213
  fullcommand({name} [, {vim9}]) String get full command from {name}
@@ -348,7 +348,7 @@ job_start({command} [, {options}])
348
  Job start a job
349
  job_status({job}) String get the status of {job}
350
  job_stop({job} [, {how}]) Number stop {job}
351
- join({list} [, {sep}]) String join {list} items into one String
352
  js_decode({string}) any decode JS style JSON
353
  js_encode({expr}) String encode JS style JSON
354
  json_decode({string}) any decode JSON
@@ -364,6 +364,7 @@ line2byte({lnum}) Number byte count of line {lnum}
364
  lispindent({lnum}) Number Lisp indent for line {lnum}
365
  list2blob({list}) Blob turn {list} of numbers into a Blob
366
  list2str({list} [, {utf8}]) String turn {list} of numbers into a String
 
367
  listener_add({callback} [, {buf}])
368
  Number add a callback to listen to changes
369
  listener_flush([{buf}]) none invoke listener callbacks
@@ -511,10 +512,10 @@ remove({blob}, {idx} [, {end}]) Number/Blob
511
  remove bytes {idx}-{end} from {blob}
512
  remove({dict}, {key}) any remove entry {key} from {dict}
513
  rename({from}, {to}) Number rename (move) file from {from} to {to}
514
- repeat({expr}, {count}) List/Blob/String
515
  repeat {expr} {count} times
516
  resolve({filename}) String get filename a shortcut points to
517
- reverse({obj}) List/Blob/String
518
  reverse {obj}
519
  round({expr}) Float round off {expr}
520
  rubyeval({expr}) any evaluate |Ruby| expression
@@ -713,6 +714,7 @@ test_null_job() Job null value for testing
713
  test_null_list() List null value for testing
714
  test_null_partial() Funcref null value for testing
715
  test_null_string() String null value for testing
 
716
  test_option_not_set({name}) none reset flag indicating option was set
717
  test_override({expr}, {val}) none test with Vim internal overrides
718
  test_refcount({expr}) Number get the reference count of {expr}
@@ -734,6 +736,7 @@ tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
734
  trim({text} [, {mask} [, {dir}]])
735
  String trim characters in {mask} from {text}
736
  trunc({expr}) Float truncate Float {expr}
 
737
  type({expr}) Number type of value {expr}
738
  typename({expr}) String representation of the type of {expr}
739
  undofile({name}) String undo file name for {name}
@@ -1311,7 +1314,7 @@ blob2str({blob} [, {options}]) *blob2str()*
1311
  encoding. The value is a |String|. See
1312
  |encoding-names| for the supported values
1313
  (plus the special value "none").
1314
- *E1515*
1315
  When current 'encoding' is "utf-8", an error is given and an
1316
  empty List is returned if an invalid byte sequence is
1317
  encountered in {blob}. To suppress this validation and get
@@ -1323,9 +1326,11 @@ blob2str({blob} [, {options}]) *blob2str()*
1323
  See also |str2blob()|
1324
 
1325
  Examples: >
1326
- blob2str(0z6162) returns ["ab"]
1327
- blob2str(0zC2ABC2BB) returns ["«»"]
1328
- blob2str(0zABBB, {'encoding': 'latin1'}) returns ["«»"]
 
 
1329
  <
1330
  Can also be used as a |method|: >
1331
  GetBlob()->blob2str()
@@ -2071,7 +2076,8 @@ copy({expr}) *copy()*
2071
  that the original |List| can be changed without changing the
2072
  copy, and vice versa. But the items are identical, thus
2073
  changing an item changes the contents of both |Lists|.
2074
- A |Dictionary| is copied in a similar way as a |List|.
 
2075
  Also see |deepcopy()|.
2076
  Can also be used as a |method|: >
2077
  mylist->copy()
@@ -2114,10 +2120,10 @@ cosh({expr}) *cosh()*
2114
 
2115
  count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E706*
2116
  Return the number of times an item with value {expr} appears
2117
- in |String|, |List| or |Dictionary| {comp}.
2118
 
2119
  If {start} is given then start with the item with this index.
2120
- {start} can only be used with a |List|.
2121
 
2122
  When {ic} is given and it's |TRUE| then case is ignored.
2123
 
@@ -2237,7 +2243,8 @@ deepcopy({expr} [, {noref}]) *deepcopy()* *E698*
2237
  |Dictionary|, a copy for it is made, recursively. Thus
2238
  changing an item in the copy does not change the contents of
2239
  the original |List|.
2240
- A |Dictionary| is copied in a similar way as a |List|.
 
2241
 
2242
  When {noref} is omitted or zero a contained |List| or
2243
  |Dictionary| is only copied once. All references point to
@@ -2545,8 +2552,8 @@ echoraw({string}) *echoraw()*
2545
 
2546
  empty({expr}) *empty()*
2547
  Return the Number 1 if {expr} is empty, zero otherwise.
2548
- - A |List| or |Dictionary| is empty when it does not have any
2549
- items.
2550
  - A |String| is empty when its length is zero.
2551
  - A |Number| and |Float| are empty when their value is zero.
2552
  - |v:false|, |v:none| and |v:null| are empty, |v:true| is not.
@@ -3473,8 +3480,9 @@ foldtextresult({lnum}) *foldtextresult()*
3473
  Return type: |String|
3474
 
3475
 
3476
- foreach({expr1}, {expr2}) *foreach()*
3477
- {expr1} must be a |List|, |String|, |Blob| or |Dictionary|.
 
3478
  For each item in {expr1} execute {expr2}. {expr1} is not
3479
  modified; its values may be, as with |:lockvar| 1. |E741|
3480
  See |map()| and |filter()| to modify {expr1}.
@@ -3483,10 +3491,10 @@ foreach({expr1}, {expr2}) *foreach()*
3483
 
3484
  If {expr2} is a |string|, inside {expr2} |v:val| has the value
3485
  of the current item. For a |Dictionary| |v:key| has the key
3486
- of the current item and for a |List| |v:key| has the index of
3487
- the current item. For a |Blob| |v:key| has the index of the
3488
- current byte. For a |String| |v:key| has the index of the
3489
- current character.
3490
  Examples: >
3491
  call foreach(mylist, 'used[v:val] = true')
3492
  < This records the items that are in the {expr1} list.
@@ -3512,8 +3520,8 @@ foreach({expr1}, {expr2}) *foreach()*
3512
  Can also be used as a |method|: >
3513
  mylist->foreach(expr2)
3514
  <
3515
- Return type: |String|, |Blob| list<{type}> or dict<{type}>
3516
- depending on {expr1}
3517
 
3518
  *foreground()*
3519
  foreground() Move the Vim window to the foreground. Useful when sent from
@@ -3686,6 +3694,15 @@ get({list}, {idx} [, {default}]) *get()* *get()-list*
3686
  <
3687
  Return type: any, depending on {list}
3688
 
 
 
 
 
 
 
 
 
 
3689
  get({blob}, {idx} [, {default}]) *get()-blob*
3690
  Get byte {idx} from |Blob| {blob}. When this byte is not
3691
  available return {default}. Return -1 when {default} is
@@ -4998,6 +5015,8 @@ getregionpos({pos1}, {pos2} [, {opts}]) *getregionpos()*
4998
  Can also be used as a |method|: >
4999
  getpos('.')->getregionpos(getpos("'a"))
5000
  <
 
 
5001
  Return type: list<list<list<number>>>
5002
 
5003
 
@@ -5817,8 +5836,8 @@ id({item}) *id()*
5817
  < prevents {item} from being garbage collected and provides a
5818
  way to get the {item} from the `id`.
5819
 
5820
- {item} may be a List, Dictionary, Object, Job, Channel or
5821
- Blob. If the item is not a permitted type, or it is a null
5822
  value, then an empty String is returned.
5823
 
5824
  Can also be used as a |method|: >
@@ -5845,12 +5864,12 @@ index({object}, {expr} [, {start} [, {ic}]]) *index()*
5845
  Find {expr} in {object} and return its index. See
5846
  |indexof()| for using a lambda to select the item.
5847
 
5848
- If {object} is a |List| return the lowest index where the item
5849
- has a value equal to {expr}. There is no automatic
5850
- conversion, so the String "4" is different from the Number 4.
5851
- And the number 4 is different from the Float 4.0. The value
5852
- of 'ignorecase' is not used here, case matters as indicated by
5853
- the {ic} argument.
5854
 
5855
  If {object} is |Blob| return the lowest index where the byte
5856
  value is equal to {expr}.
@@ -5874,11 +5893,11 @@ index({object}, {expr} [, {start} [, {ic}]]) *index()*
5874
 
5875
  indexof({object}, {expr} [, {opts}]) *indexof()*
5876
  Returns the index of an item in {object} where {expr} is
5877
- v:true. {object} must be a |List| or a |Blob|.
5878
 
5879
- If {object} is a |List|, evaluate {expr} for each item in the
5880
- List until the expression is v:true and return the index of
5881
- this item.
5882
 
5883
  If {object} is a |Blob| evaluate {expr} for each byte in the
5884
  Blob until the expression is v:true and return the index of
@@ -5886,11 +5905,11 @@ indexof({object}, {expr} [, {opts}]) *indexof()*
5886
 
5887
  {expr} must be a |string| or |Funcref|.
5888
 
5889
- If {expr} is a |string|: If {object} is a |List|, inside
5890
- {expr} |v:key| has the index of the current List item and
5891
- |v:val| has the value of the item. If {object} is a |Blob|,
5892
- inside {expr} |v:key| has the index of the current byte and
5893
- |v:val| has the byte value.
5894
 
5895
  If {expr} is a |Funcref| it must take two arguments:
5896
  1. the key or the index of the current item.
@@ -6200,9 +6219,9 @@ items({dict}) *items()*
6200
  echo key .. ': ' .. value
6201
  endfor
6202
  <
6203
- A List or a String argument is also supported. In these
6204
- cases, items() returns a List with the index and the value at
6205
- the index.
6206
 
6207
  Can also be used as a |method|: >
6208
  mydict->items()
@@ -6213,16 +6232,17 @@ items({dict}) *items()*
6213
  job_ functions are documented here: |job-functions-details|
6214
 
6215
 
6216
- join({list} [, {sep}]) *join()*
6217
- Join the items in {list} together into one String.
 
6218
  When {sep} is specified it is put in between the items. If
6219
  {sep} is omitted a single space is used.
6220
  Note that {sep} is not added at the end. You might want to
6221
  add it there too: >
6222
  let lines = join(mylist, "\n") .. "\n"
6223
- < String items are used as-is. |Lists| and |Dictionaries| are
6224
- converted into a string like with |string()|.
6225
- The opposite function is |split()|.
6226
 
6227
  Can also be used as a |method|: >
6228
  mylist->join()
@@ -6316,6 +6336,8 @@ json_encode({expr}) *json_encode()*
6316
  |Funcref| not possible, error
6317
  |List| as an array (possibly null); when
6318
  used recursively: []
 
 
6319
  |Dict| as an object (possibly null); when
6320
  used recursively: {}
6321
  |Blob| as an array of the individual bytes
@@ -6364,6 +6386,8 @@ len({expr}) *len()* *E701*
6364
  used, as with |strlen()|.
6365
  When {expr} is a |List| the number of items in the |List| is
6366
  returned.
 
 
6367
  When {expr} is a |Blob| the number of bytes is returned.
6368
  When {expr} is a |Dictionary| the number of entries in the
6369
  |Dictionary| is returned.
@@ -6545,6 +6569,25 @@ list2str({list} [, {utf8}]) *list2str()*
6545
  Return type: |String|
6546
 
6547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6548
  listener_add({callback} [, {buf}]) *listener_add()*
6549
  Add a callback function that will be invoked when changes have
6550
  been made to buffer {buf}.
@@ -7277,7 +7320,7 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
7277
  returned. Zero means no limit.
7278
  camelcase Use enhanced camel case scoring making results
7279
  better suited for completion related to
7280
- programming languages. Default is v:true
7281
 
7282
  If {list} is a list of dictionaries, then the optional {dict}
7283
  argument supports the following additional items:
@@ -7460,11 +7503,12 @@ max({expr}) *max()*
7460
  Return the maximum value of all items in {expr}. Example: >
7461
  echo max([apples, pears, oranges])
7462
 
7463
- < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
7464
- it returns the maximum of all values in the Dictionary.
7465
- If {expr} is neither a List nor a Dictionary, or one of the
7466
- items in {expr} cannot be used as a Number this results in
7467
- an error. An empty |List| or |Dictionary| results in zero.
 
7468
 
7469
  Can also be used as a |method|: >
7470
  mylist->max()
@@ -7551,11 +7595,12 @@ min({expr}) *min()*
7551
  Return the minimum value of all items in {expr}. Example: >
7552
  echo min([apples, pears, oranges])
7553
 
7554
- < {expr} can be a |List| or a |Dictionary|. For a Dictionary,
7555
- it returns the minimum of all values in the Dictionary.
7556
- If {expr} is neither a List nor a Dictionary, or one of the
7557
- items in {expr} cannot be used as a Number this results in
7558
- an error. An empty |List| or |Dictionary| results in zero.
 
7559
 
7560
  Can also be used as a |method|: >
7561
  mylist->min()
@@ -8578,8 +8623,8 @@ readfile({fname} [, {type} [, {max}]])
8578
 
8579
  reduce({object}, {func} [, {initial}]) *reduce()* *E998*
8580
  {func} is called for every item in {object}, which can be a
8581
- |String|, |List| or a |Blob|. {func} is called with two
8582
- arguments: the result so far and current item. After
8583
  processing all items the result is returned. *E1132*
8584
 
8585
  {initial} is the initial result. When omitted, the first item
@@ -8900,16 +8945,16 @@ repeat({expr}, {count}) *repeat()*
8900
  result. Example: >
8901
  :let separator = repeat('-', 80)
8902
  < When {count} is zero or negative the result is empty.
8903
- When {expr} is a |List| or a |Blob| the result is {expr}
8904
- concatenated {count} times. Example: >
8905
  :let longlist = repeat(['a', 'b'], 3)
8906
  < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
8907
 
8908
  Can also be used as a |method|: >
8909
  mylist->repeat(count)
8910
  <
8911
- Return type: |String|, |Blob| or list<{type}> depending on
8912
- {expr}
8913
 
8914
 
8915
  resolve({filename}) *resolve()* *E655*
@@ -8936,18 +8981,19 @@ resolve({filename}) *resolve()* *E655*
8936
 
8937
  reverse({object}) *reverse()*
8938
  Reverse the order of items in {object}. {object} can be a
8939
- |List|, a |Blob| or a |String|. For a List and a Blob the
8940
- items are reversed in-place and {object} is returned.
 
8941
  For a String a new String is returned.
8942
- Returns zero if {object} is not a List, Blob or a String.
8943
- If you want a List or Blob to remain unmodified make a copy
8944
- first: >
8945
  :let revlist = reverse(copy(mylist))
8946
  < Can also be used as a |method|: >
8947
  mylist->reverse()
8948
  <
8949
- Return type: |String|, |Blob| or list<{type}> depending on
8950
- {object}
8951
 
8952
 
8953
  round({expr}) *round()*
@@ -10300,7 +10346,7 @@ slice({expr}, {start} [, {end}]) *slice()*
10300
  Can also be used as a |method|: >
10301
  GetList()->slice(offset)
10302
  <
10303
- Return type: list<{type}>
10304
 
10305
 
10306
  sort({list} [, {how} [, {dict}]]) *sort()* *E702*
@@ -10664,11 +10710,12 @@ str2blob({list} [, {options}]) *str2blob()*
10664
  See also |blob2str()|
10665
 
10666
  Examples: >
10667
- str2blob(["ab"]) returns 0z6162
10668
- str2blob(["«»"]) returns 0zC2ABC2BB
10669
- str2blob(["a\nb"]) returns 0z610A62
10670
- str2blob(readfile('myfile.txt'))
10671
  str2blob(["«»"], {'encoding': 'latin1'}) returns 0zABBB
 
10672
  <
10673
  Can also be used as a |method|: >
10674
  GetListOfStrings()->str2blob()
@@ -10911,15 +10958,16 @@ string({expr}) *string()*
10911
  Funcref function('name')
10912
  Blob 0z00112233.44556677.8899
10913
  List [item, item]
 
10914
  Dictionary {key: value, key: value}
10915
  Class class SomeName
10916
  Object object of SomeName {lnum: 1, col: 3}
10917
  Enum enum EnumName
10918
  EnumValue enum name.value {name: str, ordinal: nr}
10919
 
10920
- When a |List| or |Dictionary| has a recursive reference it is
10921
- replaced by "[...]" or "{...}". Using eval() on the result
10922
- will then fail.
10923
 
10924
  For an object, invokes the string() method to get a textual
10925
  representation of the object. If the method is not present,
@@ -11873,6 +11921,25 @@ trunc({expr}) *trunc()*
11873
  Return type: |Float|
11874
 
11875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11876
  *type()*
11877
  type({expr}) The result is a Number representing the type of {expr}.
11878
  Instead of using the number directly, it is better to use the
@@ -11893,6 +11960,7 @@ type({expr}) The result is a Number representing the type of {expr}.
11893
  Typealias: 14 |v:t_typealias|
11894
  Enum: 15 |v:t_enum|
11895
  EnumValue: 16 |v:t_enumvalue|
 
11896
  For backward compatibility, this method can be used: >
11897
  :if type(myvar) == type(0)
11898
  :if type(myvar) == type("")
1
+ *builtin.txt* For Vim version 9.1. Last change: 2025 Mar 23
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
207
  foldlevel({lnum}) Number fold level at {lnum}
208
  foldtext() String line displayed for closed fold
209
  foldtextresult({lnum}) String text for closed fold at {lnum}
210
+ foreach({expr1}, {expr2}) List/Tuple/Dict/Blob/String
211
  for each item in {expr1} call {expr2}
212
  foreground() Number bring the Vim window to the foreground
213
  fullcommand({name} [, {vim9}]) String get full command from {name}
348
  Job start a job
349
  job_status({job}) String get the status of {job}
350
  job_stop({job} [, {how}]) Number stop {job}
351
+ join({expr} [, {sep}]) String join items in {expr} into one String
352
  js_decode({string}) any decode JS style JSON
353
  js_encode({expr}) String encode JS style JSON
354
  json_decode({string}) any decode JSON
364
  lispindent({lnum}) Number Lisp indent for line {lnum}
365
  list2blob({list}) Blob turn {list} of numbers into a Blob
366
  list2str({list} [, {utf8}]) String turn {list} of numbers into a String
367
+ list2tuple({list}) Tuple turn {list} of items into a tuple
368
  listener_add({callback} [, {buf}])
369
  Number add a callback to listen to changes
370
  listener_flush([{buf}]) none invoke listener callbacks
512
  remove bytes {idx}-{end} from {blob}
513
  remove({dict}, {key}) any remove entry {key} from {dict}
514
  rename({from}, {to}) Number rename (move) file from {from} to {to}
515
+ repeat({expr}, {count}) List/Tuple/Blob/String
516
  repeat {expr} {count} times
517
  resolve({filename}) String get filename a shortcut points to
518
+ reverse({obj}) List/Tuple/Blob/String
519
  reverse {obj}
520
  round({expr}) Float round off {expr}
521
  rubyeval({expr}) any evaluate |Ruby| expression
714
  test_null_list() List null value for testing
715
  test_null_partial() Funcref null value for testing
716
  test_null_string() String null value for testing
717
+ test_null_tuple() Tuple null value for testing
718
  test_option_not_set({name}) none reset flag indicating option was set
719
  test_override({expr}, {val}) none test with Vim internal overrides
720
  test_refcount({expr}) Number get the reference count of {expr}
736
  trim({text} [, {mask} [, {dir}]])
737
  String trim characters in {mask} from {text}
738
  trunc({expr}) Float truncate Float {expr}
739
+ tuple2list({tuple}) List turn {tuple} of items into a list
740
  type({expr}) Number type of value {expr}
741
  typename({expr}) String representation of the type of {expr}
742
  undofile({name}) String undo file name for {name}
1314
  encoding. The value is a |String|. See
1315
  |encoding-names| for the supported values
1316
  (plus the special value "none").
1317
+ *E1515* *E1516*
1318
  When current 'encoding' is "utf-8", an error is given and an
1319
  empty List is returned if an invalid byte sequence is
1320
  encountered in {blob}. To suppress this validation and get
1326
  See also |str2blob()|
1327
 
1328
  Examples: >
1329
+ blob2str(0z6162) returns ['ab']
1330
+ blob2str(0zC2ABC2BB) returns ['«»']
1331
+ blob2str(0z610A62) returns ['a', 'b']
1332
+ blob2str(0z610062) returns ['a\nb']
1333
+ blob2str(0zABBB, {'encoding': 'latin1'}) returns ['«»']
1334
  <
1335
  Can also be used as a |method|: >
1336
  GetBlob()->blob2str()
2076
  that the original |List| can be changed without changing the
2077
  copy, and vice versa. But the items are identical, thus
2078
  changing an item changes the contents of both |Lists|.
2079
+ A |Tuple| or |Dictionary| is copied in a similar way as a
2080
+ |List|.
2081
  Also see |deepcopy()|.
2082
  Can also be used as a |method|: >
2083
  mylist->copy()
2120
 
2121
  count({comp}, {expr} [, {ic} [, {start}]]) *count()* *E706*
2122
  Return the number of times an item with value {expr} appears
2123
+ in |String|, |List|, |Tuple| or |Dictionary| {comp}.
2124
 
2125
  If {start} is given then start with the item with this index.
2126
+ {start} can only be used with a |List| or a |Tuple|.
2127
 
2128
  When {ic} is given and it's |TRUE| then case is ignored.
2129
 
2243
  |Dictionary|, a copy for it is made, recursively. Thus
2244
  changing an item in the copy does not change the contents of
2245
  the original |List|.
2246
+ A |Tuple| or |Dictionary| is copied in a similar way as a
2247
+ |List|.
2248
 
2249
  When {noref} is omitted or zero a contained |List| or
2250
  |Dictionary| is only copied once. All references point to
2552
 
2553
  empty({expr}) *empty()*
2554
  Return the Number 1 if {expr} is empty, zero otherwise.
2555
+ - A |List|, |Tuple| or |Dictionary| is empty when it does
2556
+ not have any items.
2557
  - A |String| is empty when its length is zero.
2558
  - A |Number| and |Float| are empty when their value is zero.
2559
  - |v:false|, |v:none| and |v:null| are empty, |v:true| is not.
3480
  Return type: |String|
3481
 
3482
 
3483
+ foreach({expr1}, {expr2}) *foreach()* *E1525*
3484
+ {expr1} must be a |List|, |Tuple|, |String|, |Blob| or
3485
+ |Dictionary|.
3486
  For each item in {expr1} execute {expr2}. {expr1} is not
3487
  modified; its values may be, as with |:lockvar| 1. |E741|
3488
  See |map()| and |filter()| to modify {expr1}.
3491
 
3492
  If {expr2} is a |string|, inside {expr2} |v:val| has the value
3493
  of the current item. For a |Dictionary| |v:key| has the key
3494
+ of the current item and for a |List| or a |Tuple| |v:key| has
3495
+ the index of the current item. For a |Blob| |v:key| has the
3496
+ index of the current byte. For a |String| |v:key| has the
3497
+ index of the current character.
3498
  Examples: >
3499
  call foreach(mylist, 'used[v:val] = true')
3500
  < This records the items that are in the {expr1} list.
3520
  Can also be used as a |method|: >
3521
  mylist->foreach(expr2)
3522
  <
3523
+ Return type: |String|, |Blob|, list<{type}>, tuple<{type}> or
3524
+ dict<{type}> depending on {expr1}
3525
 
3526
  *foreground()*
3527
  foreground() Move the Vim window to the foreground. Useful when sent from
3694
  <
3695
  Return type: any, depending on {list}
3696
 
3697
+ get({tuple}, {idx} [, {default}]) *get()-tuple*
3698
+ Get item {idx} from |Tuple| {tuple}. When this item is not
3699
+ available return {default}. Return zero when {default} is
3700
+ omitted.
3701
+ Preferably used as a |method|: >
3702
+ mytuple->get(idx)
3703
+ <
3704
+ Return type: any, depending on {tuple}
3705
+
3706
  get({blob}, {idx} [, {default}]) *get()-blob*
3707
  Get byte {idx} from |Blob| {blob}. When this byte is not
3708
  available return {default}. Return -1 when {default} is
5015
  Can also be used as a |method|: >
5016
  getpos('.')->getregionpos(getpos("'a"))
5017
  <
5018
+ For an example, see the highlight-yank plugin |52.6|
5019
+
5020
  Return type: list<list<list<number>>>
5021
 
5022
 
5836
  < prevents {item} from being garbage collected and provides a
5837
  way to get the {item} from the `id`.
5838
 
5839
+ {item} may be a List, Tuple, Dictionary, Object, Job, Channel
5840
+ or Blob. If the item is not a permitted type, or it is a null
5841
  value, then an empty String is returned.
5842
 
5843
  Can also be used as a |method|: >
5864
  Find {expr} in {object} and return its index. See
5865
  |indexof()| for using a lambda to select the item.
5866
 
5867
+ If {object} is a |List| or a |Tuple| return the lowest index
5868
+ where the item has a value equal to {expr}. There is no
5869
+ automatic conversion, so the String "4" is different from the
5870
+ Number 4. And the number 4 is different from the Float 4.0.
5871
+ The value of 'ignorecase' is not used here, case matters as
5872
+ indicated by the {ic} argument.
5873
 
5874
  If {object} is |Blob| return the lowest index where the byte
5875
  value is equal to {expr}.
5893
 
5894
  indexof({object}, {expr} [, {opts}]) *indexof()*
5895
  Returns the index of an item in {object} where {expr} is
5896
+ v:true. {object} must be a |List|, a |Tuple| or a |Blob|.
5897
 
5898
+ If {object} is a |List| or a |Tuple|, evaluate {expr} for each
5899
+ item in the List until the expression is v:true and return the
5900
+ index of this item.
5901
 
5902
  If {object} is a |Blob| evaluate {expr} for each byte in the
5903
  Blob until the expression is v:true and return the index of
5905
 
5906
  {expr} must be a |string| or |Funcref|.
5907
 
5908
+ If {expr} is a |string|: If {object} is a |List| or a |Tuple|,
5909
+ inside {expr} |v:key| has the index of the current List or
5910
+ Tuple item and |v:val| has the value of the item. If {object}
5911
+ is a |Blob|, inside {expr} |v:key| has the index of the
5912
+ current byte and |v:val| has the byte value.
5913
 
5914
  If {expr} is a |Funcref| it must take two arguments:
5915
  1. the key or the index of the current item.
6219
  echo key .. ': ' .. value
6220
  endfor
6221
  <
6222
+ A |List|, a |Tuple| or a |String| argument is also supported.
6223
+ In these cases, items() returns a List with the index and the
6224
+ value at the index.
6225
 
6226
  Can also be used as a |method|: >
6227
  mydict->items()
6232
  job_ functions are documented here: |job-functions-details|
6233
 
6234
 
6235
+ join({expr} [, {sep}]) *join()*
6236
+ Join the items in {expr} together into one String. {expr} can
6237
+ be a |List| or a |Tuple|.
6238
  When {sep} is specified it is put in between the items. If
6239
  {sep} is omitted a single space is used.
6240
  Note that {sep} is not added at the end. You might want to
6241
  add it there too: >
6242
  let lines = join(mylist, "\n") .. "\n"
6243
+ < String items are used as-is. |Lists|, |Tuples| and
6244
+ |Dictionaries| are converted into a string like with
6245
+ |string()|. The opposite function is |split()|.
6246
 
6247
  Can also be used as a |method|: >
6248
  mylist->join()
6336
  |Funcref| not possible, error
6337
  |List| as an array (possibly null); when
6338
  used recursively: []
6339
+ |Tuple| as an array (possibly null); when
6340
+ used recursively: []
6341
  |Dict| as an object (possibly null); when
6342
  used recursively: {}
6343
  |Blob| as an array of the individual bytes
6386
  used, as with |strlen()|.
6387
  When {expr} is a |List| the number of items in the |List| is
6388
  returned.
6389
+ When {expr} is a |Tuple| the number of items in the |Tuple| is
6390
+ returned.
6391
  When {expr} is a |Blob| the number of bytes is returned.
6392
  When {expr} is a |Dictionary| the number of entries in the
6393
  |Dictionary| is returned.
6569
  Return type: |String|
6570
 
6571
 
6572
+ list2tuple({list}) *list2tuple()*
6573
+ Create a Tuple from a shallow copy of the list items.
6574
+ Examples: >
6575
+ list2tuple([1, 2, 3]) returns (1, 2, 3)
6576
+ < |tuple2list()| does the opposite.
6577
+
6578
+ This function doesn't recursively convert all the List items
6579
+ in {list} to a Tuple. Note that the items are identical
6580
+ between the list and the tuple, changing an item changes the
6581
+ contents of both the tuple and the list.
6582
+
6583
+ Returns an empty tuple on error.
6584
+
6585
+ Can also be used as a |method|: >
6586
+ GetList()->list2tuple()
6587
+ <
6588
+ Return type: tuple<{type}> (depending on the given |List|)
6589
+
6590
+
6591
  listener_add({callback} [, {buf}]) *listener_add()*
6592
  Add a callback function that will be invoked when changes have
6593
  been made to buffer {buf}.
7320
  returned. Zero means no limit.
7321
  camelcase Use enhanced camel case scoring making results
7322
  better suited for completion related to
7323
+ programming languages. Defaults to v:true.
7324
 
7325
  If {list} is a list of dictionaries, then the optional {dict}
7326
  argument supports the following additional items:
7503
  Return the maximum value of all items in {expr}. Example: >
7504
  echo max([apples, pears, oranges])
7505
 
7506
+ < {expr} can be a |List|, a |Tuple| or a |Dictionary|. For a
7507
+ Dictionary, it returns the maximum of all values in the
7508
+ Dictionary. If {expr} is neither a List nor a Tuple nor a
7509
+ Dictionary, or one of the items in {expr} cannot be used as a
7510
+ Number this results in an error. An empty |List|, |Tuple|
7511
+ or |Dictionary| results in zero.
7512
 
7513
  Can also be used as a |method|: >
7514
  mylist->max()
7595
  Return the minimum value of all items in {expr}. Example: >
7596
  echo min([apples, pears, oranges])
7597
 
7598
+ < {expr} can be a |List|, a |Tuple| or a |Dictionary|. For a
7599
+ Dictionary, it returns the minimum of all values in the
7600
+ Dictionary. If {expr} is neither a List nor a Tuple nor a
7601
+ Dictionary, or one of the items in {expr} cannot be used as a
7602
+ Number this results in an error. An empty |List|, |Tuple| or
7603
+ |Dictionary| results in zero.
7604
 
7605
  Can also be used as a |method|: >
7606
  mylist->min()
8623
 
8624
  reduce({object}, {func} [, {initial}]) *reduce()* *E998*
8625
  {func} is called for every item in {object}, which can be a
8626
+ |String|, |List|, |Tuple| or a |Blob|. {func} is called with
8627
+ two arguments: the result so far and current item. After
8628
  processing all items the result is returned. *E1132*
8629
 
8630
  {initial} is the initial result. When omitted, the first item
8945
  result. Example: >
8946
  :let separator = repeat('-', 80)
8947
  < When {count} is zero or negative the result is empty.
8948
+ When {expr} is a |List|, a |Tuple| or a |Blob| the result is
8949
+ {expr} concatenated {count} times. Example: >
8950
  :let longlist = repeat(['a', 'b'], 3)
8951
  < Results in ['a', 'b', 'a', 'b', 'a', 'b'].
8952
 
8953
  Can also be used as a |method|: >
8954
  mylist->repeat(count)
8955
  <
8956
+ Return type: |String|, |Blob|, list<{type}> or tuple<{type}>
8957
+ depending on {expr}
8958
 
8959
 
8960
  resolve({filename}) *resolve()* *E655*
8981
 
8982
  reverse({object}) *reverse()*
8983
  Reverse the order of items in {object}. {object} can be a
8984
+ |List|, a |Tuple|, a |Blob| or a |String|. For a List and a
8985
+ Blob the items are reversed in-place and {object} is returned.
8986
+ For a Tuple, a new Tuple is returned.
8987
  For a String a new String is returned.
8988
+ Returns zero if {object} is not a List, Tuple, Blob or a
8989
+ String. If you want a List or Blob to remain unmodified make
8990
+ a copy first: >
8991
  :let revlist = reverse(copy(mylist))
8992
  < Can also be used as a |method|: >
8993
  mylist->reverse()
8994
  <
8995
+ Return type: |String|, |Blob|, list<{type}> or tuple<{type}>
8996
+ depending on {object}
8997
 
8998
 
8999
  round({expr}) *round()*
10346
  Can also be used as a |method|: >
10347
  GetList()->slice(offset)
10348
  <
10349
+ Return type: list<{type}> or tuple<{type}>
10350
 
10351
 
10352
  sort({list} [, {how} [, {dict}]]) *sort()* *E702*
10710
  See also |blob2str()|
10711
 
10712
  Examples: >
10713
+ str2blob(["ab"]) returns 0z6162
10714
+ str2blob(["«»"]) returns 0zC2ABC2BB
10715
+ str2blob(["a\nb"]) returns 0z610062
10716
+ str2blob(["a","b"]) returns 0z610A62
10717
  str2blob(["«»"], {'encoding': 'latin1'}) returns 0zABBB
10718
+ str2blob(readfile('myfile.txt'))
10719
  <
10720
  Can also be used as a |method|: >
10721
  GetListOfStrings()->str2blob()
10958
  Funcref function('name')
10959
  Blob 0z00112233.44556677.8899
10960
  List [item, item]
10961
+ Tuple (item, item)
10962
  Dictionary {key: value, key: value}
10963
  Class class SomeName
10964
  Object object of SomeName {lnum: 1, col: 3}
10965
  Enum enum EnumName
10966
  EnumValue enum name.value {name: str, ordinal: nr}
10967
 
10968
+ When a |List|, |Tuple| or |Dictionary| has a recursive
10969
+ reference it is replaced by "[...]" or "(...)" or "{...}".
10970
+ Using eval() on the result will then fail.
10971
 
10972
  For an object, invokes the string() method to get a textual
10973
  representation of the object. If the method is not present,
11921
  Return type: |Float|
11922
 
11923
 
11924
+ tuple2list({list}) *tuple2list()*
11925
+ Create a List from a shallow copy of the tuple items.
11926
+ Examples: >
11927
+ tuple2list((1, 2, 3)) returns [1, 2, 3]
11928
+ < |list2tuple()| does the opposite.
11929
+
11930
+ This function doesn't recursively convert all the Tuple items
11931
+ in {tuple} to a List. Note that the items are identical
11932
+ between the list and the tuple, changing an item changes the
11933
+ contents of both the tuple and the list.
11934
+
11935
+ Returns an empty list on error.
11936
+
11937
+ Can also be used as a |method|: >
11938
+ GetTuple()->tuple2list()
11939
+ <
11940
+ Return type: list<{type}> (depending on the given |Tuple|)
11941
+
11942
+
11943
  *type()*
11944
  type({expr}) The result is a Number representing the type of {expr}.
11945
  Instead of using the number directly, it is better to use the
11960
  Typealias: 14 |v:t_typealias|
11961
  Enum: 15 |v:t_enum|
11962
  EnumValue: 16 |v:t_enumvalue|
11963
+ Tuple: 17 |v:t_tuple|
11964
  For backward compatibility, this method can be used: >
11965
  :if type(myvar) == type(0)
11966
  :if type(myvar) == type("")
runtime/doc/change.txt CHANGED
@@ -1,4 +1,4 @@
1
- *change.txt* For Vim version 9.1. Last change: 2024 Dec 15
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1149,6 +1149,11 @@ inside of strings can change! Also see 'softtabstop' option. >
1149
  :[line]pu[t]! [x] Put the text [from register x] before [line] (default
1150
  current line).
1151
 
 
 
 
 
 
1152
  ["x]]p or *]p* *]<MiddleMouse>*
1153
  ["x]]<MiddleMouse> Like "p", but adjust the indent to the current line.
1154
  Using the mouse only works when 'mouse' contains 'n'
1
+ *change.txt* For Vim version 9.1. Last change: 2025 Mar 18
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
1149
  :[line]pu[t]! [x] Put the text [from register x] before [line] (default
1150
  current line).
1151
 
1152
+ *:ip* *:iput*
1153
+ :[line]ip[ut] [x] like |:put|, but adjust indent to the current line
1154
+
1155
+ :[line]ip[ut]! [x] like |:put|!, but adjust indent to the current line
1156
+
1157
  ["x]]p or *]p* *]<MiddleMouse>*
1158
  ["x]]<MiddleMouse> Like "p", but adjust the indent to the current line.
1159
  Using the mouse only works when 'mouse' contains 'n'
runtime/doc/eval.txt CHANGED
@@ -1,4 +1,4 @@
1
- *eval.txt* For Vim version 9.1. Last change: 2025 Feb 23
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -21,9 +21,10 @@ a remark is given.
21
  1.1 Variable types
22
  1.2 Function references |Funcref|
23
  1.3 Lists |Lists|
24
- 1.4 Dictionaries |Dictionaries|
25
- 1.5 Blobs |Blobs|
26
- 1.6 More about variables |more-variables|
 
27
  2. Expression syntax |expression-syntax|
28
  3. Internal variable |internal-variables|
29
  4. Builtin Functions |functions|
@@ -46,8 +47,8 @@ Profiling is documented at |profiling|.
46
 
47
  1.1 Variable types ~
48
  *E712* *E896* *E897* *E899* *E1098*
49
- *E1107* *E1135* *E1138*
50
- There are ten types of variables:
51
 
52
  *Number* *Integer*
53
  Number A 32 or 64 bit signed number. |expr-number|
@@ -63,6 +64,10 @@ String A NUL terminated string of 8-bit unsigned characters (bytes).
63
  List An ordered sequence of items, see |List| for details.
64
  Example: [1, 2, ['a', 'b']]
65
 
 
 
 
 
66
  Dictionary An associative, unordered array: Each entry has a key and a
67
  value. |Dictionary|
68
  Examples:
@@ -165,16 +170,17 @@ A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE.
165
 
166
  *E611* *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910*
167
  *E913* *E974* *E975* *E976* *E1319* *E1320* *E1321* *E1322*
168
- *E1323* *E1324*
169
- |List|, |Dictionary|, |Funcref|, |Job|, |Channel|, |Blob|, |Class| and
170
- |object| types are not automatically converted.
171
 
172
  *E805* *E806* *E808*
173
  When mixing Number and Float the Number is converted to Float. Otherwise
174
  there is no automatic conversion of Float. You can use str2float() for String
175
  to Float, printf() for Float to String and float2nr() for Float to Number.
176
 
177
- *E362* *E891* *E892* *E893* *E894* *E907* *E911* *E914*
 
178
  When expecting a Float a Number can also be used, but nothing else.
179
 
180
  *no-type-checking*
@@ -267,9 +273,9 @@ position in the sequence.
267
 
268
  List creation ~
269
  *E696* *E697*
270
- A List is created with a comma-separated list of items in square brackets.
271
  Examples: >
272
- :let mylist = [1, two, 3, "four"]
273
  :let emptylist = []
274
 
275
  An item can be any expression. Using a List for an item creates a
@@ -327,13 +333,13 @@ similar to -1. >
327
  :let otherlist = mylist[:] " make a copy of the List
328
 
329
  Notice that the last index is inclusive. If you prefer using an exclusive
330
- index use the |slice()| method.
331
 
332
- If the first index is beyond the last item of the List or the second item is
333
  before the first item, the result is an empty list. There is no error
334
  message.
335
 
336
- If the second index is equal to or greater than the length of the list the
337
  length minus one is used: >
338
  :let mylist = [0, 1, 2, 3]
339
  :echo mylist[2:8] " result: [2, 3]
@@ -463,8 +469,8 @@ Changing the order of items in a list: >
463
 
464
  For loop ~
465
 
466
- The |:for| loop executes commands for each item in a List, String or Blob.
467
- A variable is set to each item in sequence. Example with a List: >
468
  :for item in mylist
469
  : call Doit(item)
470
  :endfor
@@ -497,6 +503,8 @@ It is also possible to put remaining items in a List variable: >
497
  : endif
498
  :endfor
499
 
 
 
500
  For a Blob one byte at a time is used.
501
 
502
  For a String one character, including any composing characters, is used as a
@@ -527,8 +535,206 @@ Don't forget that a combination of features can make things simple. For
527
  example, to add up all the numbers in a list: >
528
  :exe 'let sum = ' .. join(nrlist, '+')
529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
531
- 1.4 Dictionaries ~
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
  *dict* *Dict* *Dictionaries* *Dictionary*
533
  A Dictionary is an associative array: Each entry has a key and a value. The
534
  entry can be located with the key. The entries are stored without a specific
@@ -537,10 +743,10 @@ ordering.
537
 
538
  Dictionary creation ~
539
  *E720* *E721* *E722* *E723*
540
- A Dictionary is created with a comma-separated list of entries in curly
541
  braces. Each entry has a key and a value, separated by a colon. Each key can
542
  only appear once. Examples: >
543
- :let mydict = {1: 'one', 2: 'two', 3: 'three'}
544
  :let emptydict = {}
545
  < *E713* *E716* *E717*
546
  A key is always a String. You can use a Number, it will be converted to a
@@ -570,8 +776,11 @@ An extra comma after the last entry is ignored.
570
  Accessing entries ~
571
 
572
  The normal way to access an entry is by putting the key in square brackets: >
 
573
  :let val = mydict["one"]
574
  :let mydict["four"] = 4
 
 
575
 
576
  You can add new entries to an existing Dictionary this way, unlike Lists.
577
 
@@ -709,7 +918,7 @@ Functions that can be used with a Dictionary: >
709
  :call map(dict, '">> " .. v:val') " prepend ">> " to each item
710
 
711
 
712
- 1.5 Blobs ~
713
  *blob* *Blob* *Blobs* *E978*
714
  A Blob is a binary object. It can be used to read an image from a file and
715
  send it over a channel, for example.
@@ -856,7 +1065,7 @@ Making a copy of a Blob is done with the |copy()| function. Using [:] also
856
  works, as explained above.
857
 
858
 
859
- 1.6 More about variables ~
860
  *more-variables*
861
  If you need to know the type of a variable or expression, use the |type()|
862
  function.
@@ -907,16 +1116,18 @@ Expression syntax summary, from least to most significant:
907
  etc. As above, append ? for ignoring case, # for
908
  matching case
909
 
910
- expr5 is expr5 same |List|, |Dictionary| or |Blob| instance
911
- expr5 isnot expr5 different |List|, |Dictionary| or |Blob|
912
  instance
 
 
913
 
914
  |expr5| expr6
915
  expr6 << expr6 bitwise left shift
916
  expr6 >> expr6 bitwise right shift
917
 
918
  |expr6| expr7
919
- expr7 + expr7 ... number addition, list or blob concatenation
 
920
  expr7 - expr7 ... number subtraction
921
  expr7 . expr7 ... string concatenation
922
  expr7 .. expr7 ... string concatenation
@@ -935,8 +1146,10 @@ Expression syntax summary, from least to most significant:
935
  + expr9 unary plus
936
 
937
  |expr10| expr11
938
- expr10[expr1] byte of a String or item of a |List|
 
939
  expr10[expr1 : expr1] substring of a String or sublist of a |List|
 
940
  expr10.name entry in a |Dictionary|
941
  expr10(expr1, ...) function call with |Funcref| variable
942
  expr10->name(expr1, ...) |method| call
@@ -945,6 +1158,7 @@ Expression syntax summary, from least to most significant:
945
  "string" string constant, backslash is special
946
  'string' string constant, ' is doubled
947
  [expr1, ...] |List|
 
948
  {expr1: expr1, ...} |Dictionary|
949
  #{key: expr1, ...} legacy |Dictionary|
950
  &option option value
@@ -1101,10 +1315,11 @@ Examples:
1101
  "abc" == "Abc" evaluates to 1 if 'ignorecase' is set, 0 otherwise
1102
  NOTE: In |Vim9| script 'ignorecase' is not used.
1103
 
1104
- *E691* *E692*
1105
  A |List| can only be compared with a |List| and only "equal", "not equal",
1106
  "is" and "isnot" can be used. This compares the values of the list,
1107
  recursively. Ignoring case means case is ignored when comparing item values.
 
1108
 
1109
  *E735* *E736*
1110
  A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
@@ -1124,12 +1339,13 @@ Dictionary and arguments, use |get()| to get the function name: >
1124
  if get(Part1, 'name') == get(Part2, 'name')
1125
  " Part1 and Part2 refer to the same function
1126
  < *E1037*
1127
- Using "is" or "isnot" with a |List|, |Dictionary| or |Blob| checks whether
1128
- the expressions are referring to the same |List|, |Dictionary| or |Blob|
1129
- instance. A copy of a |List| is different from the original |List|. When
1130
- using "is" without a |List|, |Dictionary| or |Blob|, it is equivalent to
1131
- using "equal", using "isnot" equivalent to using "not equal". Except that
1132
- a different type means the values are different: >
 
1133
  echo 4 == '4'
1134
  1
1135
  echo 4 is '4'
@@ -1147,7 +1363,7 @@ that: >
1147
  because 'x' converted to a Number is zero. However: >
1148
  echo [0] == ['x']
1149
  0
1150
- Inside a List or Dictionary this conversion is not used.
1151
 
1152
  In |Vim9| script the types must match.
1153
 
@@ -1191,13 +1407,14 @@ topmost bit (sometimes called the sign bit) is cleared. If the right operand
1191
 
1192
  expr6 and expr7 *expr6* *expr7* *E1036* *E1051*
1193
  ---------------
1194
- expr7 + expr7 Number addition, |List| or |Blob| concatenation *expr-+*
 
1195
  expr7 - expr7 Number subtraction *expr--*
1196
  expr7 . expr7 String concatenation *expr-.*
1197
  expr7 .. expr7 String concatenation *expr-..*
1198
 
1199
  For |Lists| only "+" is possible and then both expr7 must be a list. The
1200
- result is a new list with the two lists Concatenated.
1201
 
1202
  For String concatenation ".." is preferred, since "." is ambiguous, it is also
1203
  used for |Dict| member access and floating point numbers.
@@ -1295,7 +1512,8 @@ in any order. E.g., these are all possible:
1295
  expr10->(expr1, ...)[expr1]
1296
  Evaluation is always from left to right.
1297
 
1298
- expr10[expr1] item of String or |List| *expr-[]* *E111*
 
1299
  *E909* *subscript* *E1062*
1300
  In legacy Vim script:
1301
  If expr10 is a Number or String this results in a String that contains the
@@ -1328,6 +1546,8 @@ Generally, if a |List| index is equal to or higher than the length of the
1328
  |List|, or more negative than the length of the |List|, this results in an
1329
  error.
1330
 
 
 
1331
 
1332
  expr10[expr1a : expr1b] substring or |sublist| *expr-[:]* *substring*
1333
 
@@ -1369,6 +1589,7 @@ just above. Also see |sublist| below. Examples: >
1369
  :let l = mylist[:3] " first four items
1370
  :let l = mylist[4:4] " List with one item
1371
  :let l = mylist[:] " shallow copy of a List
 
1372
 
1373
  If expr10 is a |Blob| this results in a new |Blob| with the bytes in the
1374
  indexes expr1a and expr1b, inclusive. Examples: >
@@ -2615,6 +2836,8 @@ v:t_typealias Value of |typealias| type. Read-only. See: |type()|
2615
  v:t_enum Value of |enum| type. Read-only. See: |type()|
2616
  *v:t_enumvalue* *t_enumvalue-variable*
2617
  v:t_enumvalue Value of |enumvalue| type. Read-only. See: |type()|
 
 
2618
 
2619
  *v:termresponse* *termresponse-variable*
2620
  v:termresponse The escape sequence returned by the terminal for the |t_RV|
@@ -2934,13 +3157,13 @@ declarations and assignments do not use a command. |vim9-declaration|
2934
  :let &g:{option-name} -= {expr1}
2935
  Like above, but only set the global value of an option
2936
  (if there is one). Works like |:setglobal|.
2937
- *E1093*
2938
  :let [{name1}, {name2}, ...] = {expr1} *:let-unpack* *E687* *E688*
2939
- {expr1} must evaluate to a |List|. The first item in
2940
- the list is assigned to {name1}, the second item to
2941
- {name2}, etc.
2942
  The number of names must match the number of items in
2943
- the |List|.
2944
  Each name can be one of the items of the ":let"
2945
  command as mentioned above.
2946
  Example: >
@@ -2957,16 +3180,22 @@ declarations and assignments do not use a command. |vim9-declaration|
2957
  :let [{name1}, {name2}, ...] .= {expr1}
2958
  :let [{name1}, {name2}, ...] += {expr1}
2959
  :let [{name1}, {name2}, ...] -= {expr1}
2960
- Like above, but append/add/subtract the value for each
2961
- |List| item.
 
 
 
 
2962
 
2963
  :let [{name}, ..., ; {lastname}] = {expr1} *E452*
2964
- Like |:let-unpack| above, but the |List| may have more
2965
- items than there are names. A list of the remaining
2966
- items is assigned to {lastname}. If there are no
2967
- remaining items {lastname} is set to an empty list.
 
2968
  Example: >
2969
  :let [a, b; rest] = ["aval", "bval", 3, 4]
 
2970
  <
2971
  :let [{name}, ..., ; {lastname}] .= {expr1}
2972
  :let [{name}, ..., ; {lastname}] += {expr1}
@@ -3161,23 +3390,26 @@ text...
3161
  get an error message: "E940: Cannot lock or unlock
3162
  variable {name}".
3163
 
3164
- [depth] is relevant when locking a |List| or
3165
- |Dictionary|. It specifies how deep the locking goes:
 
3166
  0 Lock the variable {name} but not its
3167
  value.
3168
- 1 Lock the |List| or |Dictionary| itself,
3169
- cannot add or remove items, but can
3170
- still change their values.
 
3171
  2 Also lock the values, cannot change
3172
  the items. If an item is a |List| or
3173
- |Dictionary|, cannot add or remove
3174
- items, but can still change the
3175
  values.
3176
- 3 Like 2 but for the |List| /
3177
- |Dictionary| in the |List| /
3178
  |Dictionary|, one level deeper.
3179
- The default [depth] is 2, thus when {name} is a |List|
3180
- or |Dictionary| the values cannot be changed.
 
3181
 
3182
  Example with [depth] 0: >
3183
  let mylist = [1, 2, 3]
@@ -3282,7 +3514,7 @@ text...
3282
  :endfo[r] *:endfo* *:endfor*
3283
  Repeat the commands between `:for` and `:endfor` for
3284
  each item in {object}. {object} can be a |List|,
3285
- a |Blob| or a |String|. *E1177*
3286
 
3287
  Variable {var} is set to the value of each item.
3288
  In |Vim9| script the loop variable must not have been
1
+ *eval.txt* For Vim version 9.1. Last change: 2025 Mar 23
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
21
  1.1 Variable types
22
  1.2 Function references |Funcref|
23
  1.3 Lists |Lists|
24
+ 1.4 Tuples |Tuples|
25
+ 1.5 Dictionaries |Dictionaries|
26
+ 1.6 Blobs |Blobs|
27
+ 1.7 More about variables |more-variables|
28
  2. Expression syntax |expression-syntax|
29
  3. Internal variable |internal-variables|
30
  4. Builtin Functions |functions|
47
 
48
  1.1 Variable types ~
49
  *E712* *E896* *E897* *E899* *E1098*
50
+ *E1107* *E1135* *E1138* *E1523*
51
+ There are eleven types of variables:
52
 
53
  *Number* *Integer*
54
  Number A 32 or 64 bit signed number. |expr-number|
64
  List An ordered sequence of items, see |List| for details.
65
  Example: [1, 2, ['a', 'b']]
66
 
67
+ Tuple An ordered immutable sequence of items, see |Tuple| for
68
+ details.
69
+ Example: (1, 2, ('a', 'b'))
70
+
71
  Dictionary An associative, unordered array: Each entry has a key and a
72
  value. |Dictionary|
73
  Examples:
170
 
171
  *E611* *E745* *E728* *E703* *E729* *E730* *E731* *E908* *E910*
172
  *E913* *E974* *E975* *E976* *E1319* *E1320* *E1321* *E1322*
173
+ *E1323* *E1324* *E1520* *E1522*
174
+ |List|, |Tuple|, |Dictionary|, |Funcref|, |Job|, |Channel|, |Blob|, |Class|
175
+ and |object| types are not automatically converted.
176
 
177
  *E805* *E806* *E808*
178
  When mixing Number and Float the Number is converted to Float. Otherwise
179
  there is no automatic conversion of Float. You can use str2float() for String
180
  to Float, printf() for Float to String and float2nr() for Float to Number.
181
 
182
+ *E362* *E891* *E892* *E893* *E894*
183
+ *E907* *E911* *E914* *E1521*
184
  When expecting a Float a Number can also be used, but nothing else.
185
 
186
  *no-type-checking*
273
 
274
  List creation ~
275
  *E696* *E697*
276
+ A List is created with a comma-separated sequence of items in square brackets.
277
  Examples: >
278
+ :let mylist = [1, "two", 3, "four"]
279
  :let emptylist = []
280
 
281
  An item can be any expression. Using a List for an item creates a
333
  :let otherlist = mylist[:] " make a copy of the List
334
 
335
  Notice that the last index is inclusive. If you prefer using an exclusive
336
+ index use the |slice()| function.
337
 
338
+ If the first index is beyond the last item of the List or the last index is
339
  before the first item, the result is an empty list. There is no error
340
  message.
341
 
342
+ If the last index is equal to or greater than the length of the list the
343
  length minus one is used: >
344
  :let mylist = [0, 1, 2, 3]
345
  :echo mylist[2:8] " result: [2, 3]
469
 
470
  For loop ~
471
 
472
+ The |:for| loop executes commands for each item in a List, Tuple, String or
473
+ Blob. A variable is set to each item in sequence. Example with a List: >
474
  :for item in mylist
475
  : call Doit(item)
476
  :endfor
503
  : endif
504
  :endfor
505
 
506
+ For a Tuple one tuple item at a time is used.
507
+
508
  For a Blob one byte at a time is used.
509
 
510
  For a String one character, including any composing characters, is used as a
535
  example, to add up all the numbers in a list: >
536
  :exe 'let sum = ' .. join(nrlist, '+')
537
 
538
+ 1.4 Tuples ~
539
+ *tuple* *Tuple* *Tuples*
540
+ *E1532* *E1533*
541
+ A Tuple is an ordered sequence of items. An item can be of any type. Items
542
+ can be accessed by their index number. A Tuple is immutable.
543
+
544
+ A Tuple uses less memory compared to a List and provides O(1) lookup time.
545
+
546
+ Tuple creation ~
547
+ *E1526* *E1527*
548
+ A Tuple is created with a comma-separated sequence of items in parentheses.
549
+ Examples: >
550
+ :let mytuple = (1, "two", 3, "four")
551
+ :let tuple = (5,)
552
+ :let emptytuple = ()
553
+
554
+ An item can be any expression. If there is only one item in the tuple, then
555
+ the item must be followed by a comma.
556
+
557
+ Using a Tuple for an item creates a Tuple of Tuples: >
558
+ :let nesttuple = ((11, 12), (21, 22), (31, 32))
559
+
560
+
561
+ Tuple index ~
562
+ *tuple-index* *E1519*
563
+ An item in the Tuple can be accessed by putting the index in square brackets
564
+ after the Tuple. Indexes are zero-based, thus the first item has index zero.
565
+ >
566
+ :let item = mytuple[0] " get the first item: 1
567
+ :let item = mytuple[2] " get the third item: 3
568
+
569
+ When the resulting item is a tuple this can be repeated: >
570
+ :let item = nesttuple[0][1] " get the first tuple, second item: 12
571
+ <
572
+ A negative index is counted from the end. Index -1 refers to the last item in
573
+ the Tuple, -2 to the last but one item, etc. >
574
+ :let last = mytuple[-1] " get the last item: "four"
575
+
576
+ To avoid an error for an invalid index use the |get()| function. When an item
577
+ is not available it returns zero or the default value you specify: >
578
+ :echo get(mytuple, idx)
579
+ :echo get(mytuple, idx, "NONE")
580
+
581
+
582
+ Tuple concatenation ~
583
+ *tuple-concatenation*
584
+ Two tuples can be concatenated with the "+" operator: >
585
+ :let longtuple = mytuple + (5, 6)
586
+ :let longtuple = (5, 6) + mytuple
587
+ To prepend or append an item, turn it into a tuple by putting () around it.
588
+ The item must be followed by a comma.
589
+
590
+ *E1540*
591
+ Two variadic tuples with same item type can be concatenated but with different
592
+ item types cannot be concatenated. Examples: >
593
+ var a: tuple<...list<number>> = (1, 2)
594
+ var b: tuple<...list<string>> = ('a', 'b')
595
+ echo a + b # not allowed
596
+
597
+ var a: tuple<number, number> = (1, 2)
598
+ var b: tuple<...list<string>> = ('a', 'b')
599
+ echo a + b # allowed
600
+
601
+ var a: tuple<...list<number>> = (1, 2)
602
+ var b: tuple<number, number> = (3, 4)
603
+ echo a + b # not allowed
604
+
605
+ var a: tuple<...list<number>> = (1, 2)
606
+ var b: tuple<number, ...list<number>> = (3, 4)
607
+ echo a + b # not allowed
608
+ <
609
+ Note that a tuple is immutable and items cannot be added or removed from a
610
+ tuple.
611
+
612
+
613
+ Subtuple ~
614
+ *subtuple*
615
+ A part of the Tuple can be obtained by specifying the first and last index,
616
+ separated by a colon in square brackets: >
617
+ :let shorttuple = mytuple[2:-1] " get Tuple (3, "four")
618
+
619
+ Omitting the first index is similar to zero. Omitting the last index is
620
+ similar to -1. >
621
+ :let endtuple = mytuple[2:] " from item 2 to the end: (3, "four")
622
+ :let shorttuple = mytuple[2:2] " Tuple with one item: (3,)
623
+ :let othertuple = mytuple[:] " make a copy of the Tuple
624
+
625
+ Notice that the last index is inclusive. If you prefer using an exclusive
626
+ index, use the |slice()| function.
627
+
628
+ If the first index is beyond the last item of the Tuple or the last index is
629
+ before the first item, the result is an empty tuple. There is no error
630
+ message.
631
+
632
+ If the last index is equal to or greater than the length of the tuple, the
633
+ length minus one is used: >
634
+ :let mytuple = (0, 1, 2, 3)
635
+ :echo mytuple[2:8] " result: (2, 3)
636
+
637
+ NOTE: mytuple[s:e] means using the variable "s:e" as index. Watch out for
638
+ using a single letter variable before the ":". Insert a space when needed:
639
+ mytuple[s : e].
640
+
641
+
642
+ Tuple identity ~
643
+ *tuple-identity*
644
+ When variable "aa" is a tuple and you assign it to another variable "bb", both
645
+ variables refer to the same tuple: >
646
+ :let aa = (1, 2, 3)
647
+ :let bb = aa
648
+ <
649
+
650
+ Making a copy of a tuple is done with the |copy()| function. Using [:] also
651
+ works, as explained above. This creates a shallow copy of the tuple: For
652
+ example, changing a list item in the tuple will also change the item in the
653
+ copied tuple: >
654
+ :let aa = ([1, 'a'], 2, 3)
655
+ :let bb = copy(aa)
656
+ :let aa[0][1] = 'aaa'
657
+ :echo aa
658
+ < ([1, aaa], 2, 3) >
659
+ :echo bb
660
+ < ([1, aaa], 2, 3)
661
+
662
+ To make a completely independent tuple, use |deepcopy()|. This also makes a
663
+ copy of the values in the tuple, recursively. Up to a hundred levels deep.
664
+
665
+ The operator "is" can be used to check if two variables refer to the same
666
+ Tuple. "isnot" does the opposite. In contrast, "==" compares if two tuples
667
+ have the same value. >
668
+ :let atuple = (1, 2, 3)
669
+ :let btuple = (1, 2, 3)
670
+ :echo atuple is btuple
671
+ < 0 >
672
+ :echo atuple == btuple
673
+ < 1
674
+
675
+ Note about comparing tuples: Two tuples are considered equal if they have the
676
+ same length and all items compare equal, as with using "==". There is one
677
+ exception: When comparing a number with a string they are considered
678
+ different. There is no automatic type conversion, as with using "==" on
679
+ variables. Example: >
680
+ echo 4 == "4"
681
+ < 1 >
682
+ echo (4,) == ("4",)
683
+ < 0
684
+
685
+ Thus comparing Tuples is more strict than comparing numbers and strings. You
686
+ can compare simple values this way too by putting them in a tuple: >
687
+
688
+ :let a = 5
689
+ :let b = "5"
690
+ :echo a == b
691
+ < 1 >
692
+ :echo (a,) == (b,)
693
+ < 0
694
+
695
 
696
+ Tuple unpack ~
697
+
698
+ To unpack the items in a tuple to individual variables, put the variables in
699
+ square brackets, like list items: >
700
+ :let [var1, var2] = mytuple
701
+
702
+ When the number of variables does not match the number of items in the tuple
703
+ this produces an error. To handle any extra items from the tuple, append ";"
704
+ and a variable name (which will then be of type tuple): >
705
+ :let [var1, var2; rest] = mytuple
706
+
707
+ This works like: >
708
+ :let var1 = mytuple[0]
709
+ :let var2 = mytuple[1]
710
+ :let rest = mytuple[2:]
711
+
712
+ Except that there is no error if there are only two items. "rest" will be an
713
+ empty tuple then.
714
+
715
+
716
+ Tuple functions ~
717
+ *E1536*
718
+ Functions that are useful with a Tuple: >
719
+ :let xs = count(tuple, 'x') " count number of 'x's in tuple
720
+ :if empty(tuple) " check if tuple is empty
721
+ :let i = index(tuple, 'x') " index of first 'x' in tuple
722
+ :let l = items(tuple) " list of items in a tuple
723
+ :let string = join(tuple, ', ') " create string from tuple items
724
+ :let l = len(tuple) " number of items in tuple
725
+ :let big = max(tuple) " maximum value in tuple
726
+ :let small = min(tuple) " minimum value in tuple
727
+ :let r = repeat(tuple, n) " repeat a tuple n times
728
+ :let r = reverse(tuple) " reverse a tuple
729
+ :let s = slice(tuple, n1, n2) " slice a tuple
730
+ :let s = string(tuple) " String representation of tuple
731
+ :let l = tuple2list(tuple) " convert a tuple to list
732
+ :let t = list2tuple(list) " convert a list to tuple
733
+ <
734
+ *E1524*
735
+ A tuple cannot be used with the |map()|, |mapnew()| and |filter()| functions.
736
+
737
+ 1.5 Dictionaries ~
738
  *dict* *Dict* *Dictionaries* *Dictionary*
739
  A Dictionary is an associative array: Each entry has a key and a value. The
740
  entry can be located with the key. The entries are stored without a specific
743
 
744
  Dictionary creation ~
745
  *E720* *E721* *E722* *E723*
746
+ A Dictionary is created with a comma-separated sequence of entries in curly
747
  braces. Each entry has a key and a value, separated by a colon. Each key can
748
  only appear once. Examples: >
749
+ :let mydict = {'one': 1, 'two': 2, 'three': 3}
750
  :let emptydict = {}
751
  < *E713* *E716* *E717*
752
  A key is always a String. You can use a Number, it will be converted to a
776
  Accessing entries ~
777
 
778
  The normal way to access an entry is by putting the key in square brackets: >
779
+ :let mydict = {'one': 1, 'two': 2, 'three': 3}
780
  :let val = mydict["one"]
781
  :let mydict["four"] = 4
782
+ :let val = mydict.one
783
+ :let mydict.four = 4
784
 
785
  You can add new entries to an existing Dictionary this way, unlike Lists.
786
 
918
  :call map(dict, '">> " .. v:val') " prepend ">> " to each item
919
 
920
 
921
+ 1.6 Blobs ~
922
  *blob* *Blob* *Blobs* *E978*
923
  A Blob is a binary object. It can be used to read an image from a file and
924
  send it over a channel, for example.
1065
  works, as explained above.
1066
 
1067
 
1068
+ 1.7 More about variables ~
1069
  *more-variables*
1070
  If you need to know the type of a variable or expression, use the |type()|
1071
  function.
1116
  etc. As above, append ? for ignoring case, # for
1117
  matching case
1118
 
1119
+ expr5 is expr5 same |List|, |Tuple|, |Dictionary| or |Blob|
 
1120
  instance
1121
+ expr5 isnot expr5 different |List|, |Tuple|, |Dictionary| or
1122
+ |Blob| instance
1123
 
1124
  |expr5| expr6
1125
  expr6 << expr6 bitwise left shift
1126
  expr6 >> expr6 bitwise right shift
1127
 
1128
  |expr6| expr7
1129
+ expr7 + expr7 ... number addition, list or tuple or blob
1130
+ concatenation
1131
  expr7 - expr7 ... number subtraction
1132
  expr7 . expr7 ... string concatenation
1133
  expr7 .. expr7 ... string concatenation
1146
  + expr9 unary plus
1147
 
1148
  |expr10| expr11
1149
+ expr10[expr1] byte of a String or item of a |List| or
1150
+ |Tuple|
1151
  expr10[expr1 : expr1] substring of a String or sublist of a |List|
1152
+ or a slice of a |Tuple|
1153
  expr10.name entry in a |Dictionary|
1154
  expr10(expr1, ...) function call with |Funcref| variable
1155
  expr10->name(expr1, ...) |method| call
1158
  "string" string constant, backslash is special
1159
  'string' string constant, ' is doubled
1160
  [expr1, ...] |List|
1161
+ (expr1, ...) |Tuple|
1162
  {expr1: expr1, ...} |Dictionary|
1163
  #{key: expr1, ...} legacy |Dictionary|
1164
  &option option value
1315
  "abc" == "Abc" evaluates to 1 if 'ignorecase' is set, 0 otherwise
1316
  NOTE: In |Vim9| script 'ignorecase' is not used.
1317
 
1318
+ *E691* *E692* *E1517* *E1518*
1319
  A |List| can only be compared with a |List| and only "equal", "not equal",
1320
  "is" and "isnot" can be used. This compares the values of the list,
1321
  recursively. Ignoring case means case is ignored when comparing item values.
1322
+ Same applies for a |Tuple|.
1323
 
1324
  *E735* *E736*
1325
  A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
1339
  if get(Part1, 'name') == get(Part2, 'name')
1340
  " Part1 and Part2 refer to the same function
1341
  < *E1037*
1342
+ Using "is" or "isnot" with a |List|, |Tuple|, |Dictionary| or |Blob| checks
1343
+ whether the expressions are referring to the same |List|, |Tuple|,
1344
+ |Dictionary| or |Blob| instance. A copy of a |List| or |Tuple| is different
1345
+ from the original |List| or |Tuple|. When using "is" without a |List|,
1346
+ |Tuple|, |Dictionary| or |Blob|, it is equivalent to using "equal", using
1347
+ "isnot" is equivalent to using "not equal". Except that a different type
1348
+ means the values are different: >
1349
  echo 4 == '4'
1350
  1
1351
  echo 4 is '4'
1363
  because 'x' converted to a Number is zero. However: >
1364
  echo [0] == ['x']
1365
  0
1366
+ Inside a List or Tuple or Dictionary this conversion is not used.
1367
 
1368
  In |Vim9| script the types must match.
1369
 
1407
 
1408
  expr6 and expr7 *expr6* *expr7* *E1036* *E1051*
1409
  ---------------
1410
+ *expr-+*
1411
+ expr7 + expr7 Number addition, |List| or |Tuple| or |Blob| concatenation
1412
  expr7 - expr7 Number subtraction *expr--*
1413
  expr7 . expr7 String concatenation *expr-.*
1414
  expr7 .. expr7 String concatenation *expr-..*
1415
 
1416
  For |Lists| only "+" is possible and then both expr7 must be a list. The
1417
+ result is a new list with the two lists concatenated. Same for a |Tuple|.
1418
 
1419
  For String concatenation ".." is preferred, since "." is ambiguous, it is also
1420
  used for |Dict| member access and floating point numbers.
1512
  expr10->(expr1, ...)[expr1]
1513
  Evaluation is always from left to right.
1514
 
1515
+ *expr-[]* *E111*
1516
+ expr10[expr1] item of String or |List| or |Tuple|
1517
  *E909* *subscript* *E1062*
1518
  In legacy Vim script:
1519
  If expr10 is a Number or String this results in a String that contains the
1546
  |List|, or more negative than the length of the |List|, this results in an
1547
  error.
1548
 
1549
+ A |Tuple| index is similar to a |List| index as explained above.
1550
+
1551
 
1552
  expr10[expr1a : expr1b] substring or |sublist| *expr-[:]* *substring*
1553
 
1589
  :let l = mylist[:3] " first four items
1590
  :let l = mylist[4:4] " List with one item
1591
  :let l = mylist[:] " shallow copy of a List
1592
+ A |Tuple| slice is similar to a |List| slice.
1593
 
1594
  If expr10 is a |Blob| this results in a new |Blob| with the bytes in the
1595
  indexes expr1a and expr1b, inclusive. Examples: >
2836
  v:t_enum Value of |enum| type. Read-only. See: |type()|
2837
  *v:t_enumvalue* *t_enumvalue-variable*
2838
  v:t_enumvalue Value of |enumvalue| type. Read-only. See: |type()|
2839
+ *v:t_tuple* *t_tuple-variable*
2840
+ v:t_tuple Value of |Tuple| type. Read-only. See: |type()|
2841
 
2842
  *v:termresponse* *termresponse-variable*
2843
  v:termresponse The escape sequence returned by the terminal for the |t_RV|
3157
  :let &g:{option-name} -= {expr1}
3158
  Like above, but only set the global value of an option
3159
  (if there is one). Works like |:setglobal|.
3160
+ *E1093* *E1537* *E1538* *E1535*
3161
  :let [{name1}, {name2}, ...] = {expr1} *:let-unpack* *E687* *E688*
3162
+ {expr1} must evaluate to a |List| or a |Tuple|. The
3163
+ first item in the list or tuple is assigned to
3164
+ {name1}, the second item to {name2}, etc.
3165
  The number of names must match the number of items in
3166
+ the |List| or |Tuple|.
3167
  Each name can be one of the items of the ":let"
3168
  command as mentioned above.
3169
  Example: >
3180
  :let [{name1}, {name2}, ...] .= {expr1}
3181
  :let [{name1}, {name2}, ...] += {expr1}
3182
  :let [{name1}, {name2}, ...] -= {expr1}
3183
+ :let [{name1}, {name2}, ...] *= {expr1}
3184
+ :let [{name1}, {name2}, ...] /= {expr1}
3185
+ :let [{name1}, {name2}, ...] %= {expr1}
3186
+ Like above, but append, add, subtract, multiply,
3187
+ divide, or modulo the value for each |List| or |Tuple|
3188
+ item.
3189
 
3190
  :let [{name}, ..., ; {lastname}] = {expr1} *E452*
3191
+ Like |:let-unpack| above, but the |List| or |Tuple|
3192
+ may have more items than there are names. A list or a
3193
+ tuple of the remaining items is assigned to
3194
+ {lastname}. If there are no remaining items,
3195
+ {lastname} is set to an empty list or tuple.
3196
  Example: >
3197
  :let [a, b; rest] = ["aval", "bval", 3, 4]
3198
+ :let [a, b; rest] = ("aval", "bval", 3, 4)
3199
  <
3200
  :let [{name}, ..., ; {lastname}] .= {expr1}
3201
  :let [{name}, ..., ; {lastname}] += {expr1}
3390
  get an error message: "E940: Cannot lock or unlock
3391
  variable {name}".
3392
 
3393
+ [depth] is relevant when locking a |List|, a |Tuple|
3394
+ or a |Dictionary|. It specifies how deep the locking
3395
+ goes:
3396
  0 Lock the variable {name} but not its
3397
  value.
3398
+ 1 Lock the |List| or |Tuple| or
3399
+ |Dictionary| itself, cannot add or
3400
+ remove items, but can still change
3401
+ their values.
3402
  2 Also lock the values, cannot change
3403
  the items. If an item is a |List| or
3404
+ |Tuple| or |Dictionary|, cannot add or
3405
+ remove items, but can still change the
3406
  values.
3407
+ 3 Like 2 but for the |List| / |Tuple| /
3408
+ |Dictionary| in the |List| / |Tuple| /
3409
  |Dictionary|, one level deeper.
3410
+ The default [depth] is 2, thus when {name} is a
3411
+ |List|, a |Tuple| or a |Dictionary| the values cannot
3412
+ be changed.
3413
 
3414
  Example with [depth] 0: >
3415
  let mylist = [1, 2, 3]
3514
  :endfo[r] *:endfo* *:endfor*
3515
  Repeat the commands between `:for` and `:endfor` for
3516
  each item in {object}. {object} can be a |List|,
3517
+ a |Tuple|, a |Blob| or a |String|. *E1177*
3518
 
3519
  Variable {var} is set to the value of each item.
3520
  In |Vim9| script the loop variable must not have been
runtime/doc/index.txt CHANGED
@@ -1,4 +1,4 @@
1
- *index.txt* For Vim version 9.1. Last change: 2025 Jan 03
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1400,6 +1400,8 @@ tag command action ~
1400
  |:inoremenu| :inoreme[nu] like ":noremenu" but for Insert mode
1401
  |:intro| :int[ro] print the introductory message
1402
  |:interface| :interface start of an interface declaration
 
 
1403
  |:isearch| :is[earch] list one line where identifier matches
1404
  |:isplit| :isp[lit] split window and jump to definition of
1405
  identifier
1
+ *index.txt* For Vim version 9.1. Last change: 2025 Mar 18
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
1400
  |:inoremenu| :inoreme[nu] like ":noremenu" but for Insert mode
1401
  |:intro| :int[ro] print the introductory message
1402
  |:interface| :interface start of an interface declaration
1403
+ |:iput| :ip[ut] like |:put|, but adjust the indent to the
1404
+ current line
1405
  |:isearch| :is[earch] list one line where identifier matches
1406
  |:isplit| :isp[lit] split window and jump to definition of
1407
  identifier
runtime/doc/pattern.txt CHANGED
@@ -1,4 +1,4 @@
1
- *pattern.txt* For Vim version 9.1. Last change: 2024 Dec 26
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -141,6 +141,7 @@ CTRL-C Interrupt current (search) command. Use CTRL-Break on
141
  help users who use "vim file | grep word" and don't
142
  know how to get out (blindly typing :qa<CR> would
143
  work).
 
144
 
145
  *:noh* *:nohlsearch*
146
  :noh[lsearch] Stop the highlighting for the 'hlsearch' option. It
1
+ *pattern.txt* For Vim version 9.1. Last change: 2025 Mar 21
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
141
  help users who use "vim file | grep word" and don't
142
  know how to get out (blindly typing :qa<CR> would
143
  work).
144
+ If a popup is open, the active popup will be closed.
145
 
146
  *:noh* *:nohlsearch*
147
  :noh[lsearch] Stop the highlighting for the 'hlsearch' option. It
runtime/doc/syntax.txt CHANGED
@@ -1,4 +1,4 @@
1
- *syntax.txt* For Vim version 9.1. Last change: 2025 Mar 15
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3512,25 +3512,25 @@ cases pertain, then the first line of the file is examined (ex. looking for
3512
  /bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype, then
3513
  that shelltype is used. However some files (ex. .profile) are known to be
3514
  shell files but the type is not apparent. Furthermore, on many systems sh is
3515
- symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
3516
 
3517
  One may specify a global default by instantiating one of the following
3518
  variables in your <.vimrc>:
3519
 
3520
  ksh: >
3521
  let g:is_kornshell = 1
3522
- < posix: (using this is nearly the same as setting g:is_kornshell to 1) >
3523
  let g:is_posix = 1
3524
  < bash: >
3525
  let g:is_bash = 1
3526
- < sh: (default) Bourne shell >
 
 
3527
  let g:is_sh = 1
3528
 
3529
- < (dash users should use posix)
3530
-
3531
  If there's no "#! ..." line, and the user hasn't availed himself/herself of a
3532
  default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
3533
- the Bourne shell syntax. No need to quote RFCs or market penetration
3534
  statistics in error reports, please -- just select the default version of the
3535
  sh your system uses and install the associated "let..." in your <.vimrc>.
3536
 
1
+ *syntax.txt* For Vim version 9.1. Last change: 2025 Mar 21
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
3512
  /bin/sh /bin/ksh /bin/bash). If the first line specifies a shelltype, then
3513
  that shelltype is used. However some files (ex. .profile) are known to be
3514
  shell files but the type is not apparent. Furthermore, on many systems sh is
3515
+ symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (POSIX).
3516
 
3517
  One may specify a global default by instantiating one of the following
3518
  variables in your <.vimrc>:
3519
 
3520
  ksh: >
3521
  let g:is_kornshell = 1
3522
+ < posix: (default) >
3523
  let g:is_posix = 1
3524
  < bash: >
3525
  let g:is_bash = 1
3526
+ < dash: >
3527
+ let g:is_dash = 1
3528
+ < sh: Bourne shell >
3529
  let g:is_sh = 1
3530
 
 
 
3531
  If there's no "#! ..." line, and the user hasn't availed himself/herself of a
3532
  default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
3533
+ the POSIX shell syntax. No need to quote RFCs or market penetration
3534
  statistics in error reports, please -- just select the default version of the
3535
  sh your system uses and install the associated "let..." in your <.vimrc>.
3536
 
runtime/doc/testing.txt CHANGED
@@ -1,4 +1,4 @@
1
- *testing.txt* For Vim version 9.1. Last change: 2024 Jul 18
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -364,6 +364,11 @@ test_null_string() *test_null_string()*
364
 
365
  Return type: |String|
366
 
 
 
 
 
 
367
  test_option_not_set({name}) *test_option_not_set()*
368
  Reset the flag that indicates option {name} was set. Thus it
369
  looks like it still has the default value. Use like this: >
1
+ *testing.txt* For Vim version 9.1. Last change: 2025 Mar 23
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
364
 
365
  Return type: |String|
366
 
367
+ test_null_tuple() *test_null_tuple()*
368
+ Return a |Tuple| that is null. Only useful for testing.
369
+
370
+ Return type: |Tuple|
371
+
372
  test_option_not_set({name}) *test_option_not_set()*
373
  Reset the flag that indicates option {name} was set. Thus it
374
  looks like it still has the default value. Use like this: >
runtime/doc/usr_05.txt CHANGED
@@ -1,4 +1,4 @@
1
- *usr_05.txt* For Vim version 9.1. Last change: 2025 Jan 11
2
 
3
  VIM USER MANUAL - by Bram Moolenaar
4
 
@@ -437,7 +437,7 @@ After restarting your Vim, the plugin is active and you can read about it at: >
437
  :h editorconfig.txt
438
 
439
 
440
- Adding comment package *comment-install* *package-comment*
441
 
442
  Load the plugin with this command: >
443
  packadd comment
@@ -450,7 +450,7 @@ the package loaded. Once the package is loaded, read about it at: >
450
  :h comment.txt
451
 
452
 
453
- Adding nohlsearch package *nohlsearch-install* *package-nohlsearch*
454
 
455
  Load the plugin with this command: >
456
  packadd nohlsearch
@@ -464,6 +464,31 @@ To disable the effect of the plugin after it has been loaded: >
464
  au! nohlsearch
465
  <
466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
 
468
  More information about packages can be found here: |packages|.
469
 
1
+ *usr_05.txt* For Vim version 9.1. Last change: 2025 Mar 22
2
 
3
  VIM USER MANUAL - by Bram Moolenaar
4
 
437
  :h editorconfig.txt
438
 
439
 
440
+ Adding the comment package *comment-install* *package-comment*
441
 
442
  Load the plugin with this command: >
443
  packadd comment
450
  :h comment.txt
451
 
452
 
453
+ Adding the nohlsearch package *nohlsearch-install* *package-nohlsearch*
454
 
455
  Load the plugin with this command: >
456
  packadd nohlsearch
464
  au! nohlsearch
465
  <
466
 
467
+ Adding the highlight-yank package *hlyank-install* *package-hlyank*
468
+
469
+ Load the plugin with this command: >
470
+ packadd hlyank
471
+ <
472
+ This package briefly highlights the affected region of the last |yank|
473
+ command. See |52.6| for a simplified implementation using the
474
+ |getregionpos()| function.
475
+
476
+ The plugin understands the following configuration variables (the settings
477
+ show the default values).
478
+
479
+ To specify a different highlighting group, use: >
480
+ :let g:hlyank_hlgroup = 'IncSearch'
481
+ <
482
+ To use a different highlighting duration, use: >
483
+ :let g:hlyank_duration = 300
484
+ The unit is milliseconds, and the upper limit is 3000 ms. If you set a value
485
+ higher than this, the highlighting duration will be 3000 ms.
486
+
487
+ To highlight in visual mode, use: >
488
+ :let g:hlyank_invisual = v:true
489
+
490
+ To disable the effect of the plugin after it has been loaded: >
491
+ au! hlyank
492
 
493
  More information about packages can be found here: |packages|.
494
 
runtime/doc/usr_41.txt CHANGED
@@ -1,4 +1,4 @@
1
- *usr_41.txt* For Vim version 9.1. Last change: 2025 Feb 01
2
 
3
  VIM USER MANUAL - by Bram Moolenaar
4
 
@@ -839,6 +839,30 @@ List manipulation: *list-functions*
839
  repeat() repeat a List multiple times
840
  flatten() flatten a List
841
  flattennew() flatten a copy of a List
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
842
 
843
  Dictionary manipulation: *dict-functions*
844
  get() get an entry without an error for a wrong key
@@ -1234,6 +1258,7 @@ Testing: *test-functions*
1234
  test_null_list() return a null List
1235
  test_null_partial() return a null Partial function
1236
  test_null_string() return a null String
 
1237
  test_settime() set the time Vim uses internally
1238
  test_setmouse() set the mouse position
1239
  test_feedinput() add key sequence to input buffer
@@ -1649,8 +1674,8 @@ More information about defining your own functions here: |user-functions|.
1649
  ==============================================================================
1650
  *41.8* Lists and Dictionaries
1651
 
1652
- So far we have used the basic types String and Number. Vim also supports two
1653
- composite types: List and Dictionary.
1654
 
1655
  A List is an ordered sequence of items. The items can be any kind of value,
1656
  thus you can make a List of numbers, a List of Lists and even a List of mixed
@@ -1751,6 +1776,23 @@ This looks into lines 1 to 50 (inclusive) and echoes any date found in there.
1751
 
1752
  For further reading see |Lists|.
1753
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1754
 
1755
  DICTIONARIES
1756
 
1
+ *usr_41.txt* For Vim version 9.1. Last change: 2025 Mar 23
2
 
3
  VIM USER MANUAL - by Bram Moolenaar
4
 
839
  repeat() repeat a List multiple times
840
  flatten() flatten a List
841
  flattennew() flatten a copy of a List
842
+ items() get List of List index-value pairs
843
+
844
+ Tuple manipulation: *tuple-functions*
845
+ copy() make a shallow copy of a Tuple
846
+ count() count number of times a value appears in a
847
+ Tuple
848
+ deepcopy() make a full copy of a Tuple
849
+ empty() check if Tuple is empty
850
+ foreach() apply function to Tuple items
851
+ get() get an item without error for wrong index
852
+ index() index of a value in a Tuple
853
+ indexof() index in a Tuple where an expression is true
854
+ items() get List of Tuple index-value pairs
855
+ join() join Tuple items into a String
856
+ len() number of items in a Tuple
857
+ list2tuple() convert a list of items into a Tuple
858
+ max() maximum value in a Tuple
859
+ min() minimum value in a Tuple
860
+ reduce() reduce a Tuple to a value
861
+ repeat() repeat a Tuple multiple times
862
+ reverse() reverse the order of items in a Tuple
863
+ slice() take a slice of a Tuple
864
+ string() string representation of a Tuple
865
+ tuple2list() convert a Tuple of items into a list
866
 
867
  Dictionary manipulation: *dict-functions*
868
  get() get an entry without an error for a wrong key
1258
  test_null_list() return a null List
1259
  test_null_partial() return a null Partial function
1260
  test_null_string() return a null String
1261
+ test_null_tuple() return a null Tuple
1262
  test_settime() set the time Vim uses internally
1263
  test_setmouse() set the mouse position
1264
  test_feedinput() add key sequence to input buffer
1674
  ==============================================================================
1675
  *41.8* Lists and Dictionaries
1676
 
1677
+ So far we have used the basic types String and Number. Vim also supports
1678
+ three composite types: List, Tuple and Dictionary.
1679
 
1680
  A List is an ordered sequence of items. The items can be any kind of value,
1681
  thus you can make a List of numbers, a List of Lists and even a List of mixed
1776
 
1777
  For further reading see |Lists|.
1778
 
1779
+ TUPLE
1780
+
1781
+ A Tuple is an immutable ordered sequence of items. An item can be of any
1782
+ type. Items can be accessed by their index number. To create a Tuple with
1783
+ three strings: >
1784
+
1785
+ var atuple = ('one', 'two', 'three')
1786
+
1787
+ The Tuple items are enclosed in parenthesis and separated by commas. To
1788
+ create an empty Tuple: >
1789
+
1790
+ var atuple = ()
1791
+
1792
+ The |:for| loop can be used to iterate over the items in a Tuple similar to a
1793
+ List.
1794
+
1795
+ For further reading see |Tuples|.
1796
 
1797
  DICTIONARIES
1798
 
runtime/doc/usr_52.txt CHANGED
@@ -1,4 +1,4 @@
1
- *usr_52.txt* For Vim version 9.1. Last change: 2025 Mar 12
2
 
3
  VIM USER MANUAL - by Bram Moolenaar
4
 
@@ -346,11 +346,8 @@ Have a look at the package located at $VIMRUNTIME/pack/dist/opt/comment/
346
 
347
  HIGHLIGHT YANK PLUGIN
348
 
349
- Here is an example for highlighting the yanked region. It makes use of the
350
- |getregionpos()| function, available since Vim 9.1.0446.
351
-
352
- Copy the following example into a new file and place it into your plugin directory
353
- and it will be active next time you start Vim. |add-plugin|: >
354
 
355
  vim9script
356
 
@@ -375,6 +372,9 @@ and it will be active next time you start Vim. |add-plugin|: >
375
 
376
  autocmd TextYankPost * HighlightedYank()
377
  <
 
 
 
378
  ==============================================================================
379
 
380
  Next chapter: |usr_90.txt| Installing Vim
1
+ *usr_52.txt* For Vim version 9.1. Last change: 2025 Mar 17
2
 
3
  VIM USER MANUAL - by Bram Moolenaar
4
 
346
 
347
  HIGHLIGHT YANK PLUGIN
348
 
349
+ Vim comes with the highlight-yank plugin, written in Vim9 script
350
+ |hlyank-install|, here is a simplified implementation: >vim
 
 
 
351
 
352
  vim9script
353
 
372
 
373
  autocmd TextYankPost * HighlightedYank()
374
  <
375
+ For the complete example, have a look into the package located at
376
+ `$VIMRUNTIME/pack/dist/opt/hlyank/`
377
+
378
  ==============================================================================
379
 
380
  Next chapter: |usr_90.txt| Installing Vim
runtime/doc/version9.txt CHANGED
@@ -1,4 +1,4 @@
1
- *version9.txt* For Vim version 9.1. Last change: 2025 Mar 15
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -41556,7 +41556,8 @@ Support for protected _new() method
41556
  *new-other-9.2*
41557
  Other new features ~
41558
  ------------------
41559
- The new plugins |comment-install| and |nohlsearch-install| are included.
 
41560
 
41561
  Support for Wayland UI.
41562
 
@@ -41573,6 +41574,8 @@ Include the "linematch" algorithm for the 'diffopt' setting. This aligns
41573
  changes between buffers on similar lines improving the diff highlighting in
41574
  Vim
41575
 
 
 
41576
  *changed-9.2*
41577
  Changed~
41578
  -------
@@ -41652,6 +41655,7 @@ Others: ~
41652
  - add |dist#vim9#Launch()| and |dist#vim9#Open()| to the |vim-script-library|
41653
  and decouple it from |netrw|
41654
  - new digraph "APPROACHES THE LIMIT" using ".="
 
41655
 
41656
  *added-9.2*
41657
  Added ~
@@ -41675,11 +41679,14 @@ Functions: ~
41675
  |getstacktrace()| get current stack trace of Vim scripts
41676
  |id()| get unique identifier for a Dict, List, Object,
41677
  Channel or Blob variable
 
41678
  |matchbufline()| all the matches of a pattern in a buffer
41679
  |matchstrlist()| all the matches of a pattern in a List of strings
41680
  |ngettext()| lookup single/plural message translation
41681
  |popup_setbuf()| switch to a different buffer in a popup
41682
  |str2blob()| convert a List of strings into a blob
 
 
41683
 
41684
 
41685
  Autocommands: ~
@@ -41704,6 +41711,10 @@ Highlighting: ~
41704
  Commands: ~
41705
 
41706
  |[r| and |]r| to move the cursor to previous/next rare word
 
 
 
 
41707
  |:pbuffer| Edit buffer [N] from the buffer list in the preview
41708
  window
41709
 
1
+ *version9.txt* For Vim version 9.1. Last change: 2025 Mar 23
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
41556
  *new-other-9.2*
41557
  Other new features ~
41558
  ------------------
41559
+ The new packages |package-comment|, |package-nohlsearch| and |package-hlyank|
41560
+ are included.
41561
 
41562
  Support for Wayland UI.
41563
 
41574
  changes between buffers on similar lines improving the diff highlighting in
41575
  Vim
41576
 
41577
+ Support for the |Tuple| data type in Vim script and Vim9 script.
41578
+
41579
  *changed-9.2*
41580
  Changed~
41581
  -------
41655
  - add |dist#vim9#Launch()| and |dist#vim9#Open()| to the |vim-script-library|
41656
  and decouple it from |netrw|
41657
  - new digraph "APPROACHES THE LIMIT" using ".="
41658
+ - |CTRL-C| always closes the active |popup-window|.
41659
 
41660
  *added-9.2*
41661
  Added ~
41679
  |getstacktrace()| get current stack trace of Vim scripts
41680
  |id()| get unique identifier for a Dict, List, Object,
41681
  Channel or Blob variable
41682
+ |list2tuple()| turn a List of items into a Tuple
41683
  |matchbufline()| all the matches of a pattern in a buffer
41684
  |matchstrlist()| all the matches of a pattern in a List of strings
41685
  |ngettext()| lookup single/plural message translation
41686
  |popup_setbuf()| switch to a different buffer in a popup
41687
  |str2blob()| convert a List of strings into a blob
41688
+ |test_null_tuple()| return a null tuple
41689
+ |tuple2list()| turn a Tuple of items into a List
41690
 
41691
 
41692
  Autocommands: ~
41711
  Commands: ~
41712
 
41713
  |[r| and |]r| to move the cursor to previous/next rare word
41714
+
41715
+ Ex-Commands: ~
41716
+
41717
+ |:iput| like |:put| but adjust indent
41718
  |:pbuffer| Edit buffer [N] from the buffer list in the preview
41719
  window
41720
 
runtime/doc/vim9.txt CHANGED
@@ -1,4 +1,4 @@
1
- *vim9.txt* For Vim version 9.1. Last change: 2025 Mar 06
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1001,6 +1001,7 @@ empty list and dict is falsy:
1001
  string non-empty
1002
  blob non-empty
1003
  list non-empty (different from JavaScript)
 
1004
  dictionary non-empty (different from JavaScript)
1005
  func when there is a function name
1006
  special true or v:true
@@ -1048,6 +1049,7 @@ In Vim9 script one can use the following predefined values: >
1048
  null_function
1049
  null_job
1050
  null_list
 
1051
  null_object
1052
  null_partial
1053
  null_string
@@ -1467,15 +1469,16 @@ The following builtin types are supported:
1467
  dict<{type}>
1468
  job
1469
  channel
 
 
 
 
1470
  func
1471
  func: {type}
1472
  func({type}, ...)
1473
  func({type}, ...): {type}
1474
  void
1475
 
1476
- Not supported yet:
1477
- tuple<a: {type}, b: {type}, ...>
1478
-
1479
  These types can be used in declarations, but no simple value will actually
1480
  have the "void" type. Trying to use a void (e.g. a function without a
1481
  return value) results in error *E1031* *E1186* .
@@ -1483,6 +1486,32 @@ return value) results in error *E1031* *E1186* .
1483
  There is no array type, use list<{type}> instead. For a list constant an
1484
  efficient implementation is used that avoids allocating a lot of small pieces
1485
  of memory.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1486
  *vim9-func-declaration* *E1005* *E1007*
1487
  A partial and function can be declared in more or less specific ways:
1488
  func any kind of function reference, no type
@@ -1707,7 +1736,8 @@ argument type checking: >
1707
  *E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
1708
  *E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
1709
  *E1228* *E1238* *E1250* *E1251* *E1252* *E1256*
1710
- *E1297* *E1298* *E1301*
 
1711
  Types are checked for most builtin functions to make it easier to spot
1712
  mistakes.
1713
 
@@ -1715,7 +1745,7 @@ Categories of variables, defaults and null handling ~
1715
  *variable-categories* *null-variables*
1716
  There are categories of variables:
1717
  primitive number, float, boolean
1718
- container string, blob, list, dict
1719
  specialized function, job, channel, user-defined-object
1720
 
1721
  When declaring a variable without an initializer, an explicit type must be
@@ -1845,6 +1875,7 @@ An uninitialized variable is usually equal to null; it depends on its type:
1845
  var s: string s == null
1846
  var b: blob b != null ***
1847
  var l: list<any> l != null ***
 
1848
  var d: dict<any> d != null ***
1849
  var f: func f == null
1850
  var j: job j == null
@@ -1855,6 +1886,7 @@ A variable initialized to empty equals null_<type>; but not null:
1855
  var s2: string = "" == null_string != null
1856
  var b2: blob = 0z == null_blob != null
1857
  var l2: list<any> = [] == null_list != null
 
1858
  var d2: dict<any> = {} == null_dict != null
1859
 
1860
  NOTE: the specialized variables, like job, default to null value and have no
1
+ *vim9.txt* For Vim version 9.1. Last change: 2025 Mar 23
2
 
3
 
4
  VIM REFERENCE MANUAL by Bram Moolenaar
1001
  string non-empty
1002
  blob non-empty
1003
  list non-empty (different from JavaScript)
1004
+ tuple non-empty (different from JavaScript)
1005
  dictionary non-empty (different from JavaScript)
1006
  func when there is a function name
1007
  special true or v:true
1049
  null_function
1050
  null_job
1051
  null_list
1052
+ null_tuple
1053
  null_object
1054
  null_partial
1055
  null_string
1469
  dict<{type}>
1470
  job
1471
  channel
1472
+ tuple<{type}>
1473
+ tuple<{type}, {type}, ...>
1474
+ tuple<...list<{type}>>
1475
+ tuple<{type}, ...list<{type}>>
1476
  func
1477
  func: {type}
1478
  func({type}, ...)
1479
  func({type}, ...): {type}
1480
  void
1481
 
 
 
 
1482
  These types can be used in declarations, but no simple value will actually
1483
  have the "void" type. Trying to use a void (e.g. a function without a
1484
  return value) results in error *E1031* *E1186* .
1486
  There is no array type, use list<{type}> instead. For a list constant an
1487
  efficient implementation is used that avoids allocating a lot of small pieces
1488
  of memory.
1489
+ *tuple-type*
1490
+ A tuple type can be declared in more or less specific ways:
1491
+ tuple<number> a tuple with a single item of type |Number|
1492
+ tuple<number, string> a tuple with two items of type |Number| and
1493
+ |String|
1494
+ tuple<number, float, bool> a tuple with three items of type |Number|,
1495
+ |Float| and |Boolean|.
1496
+ tuple<...list<number>> a variadic tuple with zero or more items of
1497
+ type |Number|.
1498
+ tuple<number, ...list<string>> a tuple with an item of type |Number| followed
1499
+ by zero or more items of type |String|.
1500
+
1501
+ Examples: >
1502
+ var myTuple: tuple<number> = (20,)
1503
+ var myTuple: tuple<number, string> = (30, 'vim')
1504
+ var myTuple: tuple<number, float, bool> = (40, 1.1, true)
1505
+ var myTuple: tuple<...list<string>> = ('a', 'b', 'c')
1506
+ var myTuple: tuple<number, ...list<string>> = (3, 'a', 'b', 'c')
1507
+ <
1508
+ *variadic-tuple* *E1539*
1509
+ A variadic tuple has zero or more items of the same type. The type of a
1510
+ variadic tuple must end with a list type. Examples: >
1511
+ var myTuple: tuple<...list<number>> = (1, 2, 3)
1512
+ var myTuple: tuple<...list<string>> = ('a', 'b', 'c')
1513
+ var myTuple: tuple<...list<bool>> = ()
1514
+ <
1515
  *vim9-func-declaration* *E1005* *E1007*
1516
  A partial and function can be declared in more or less specific ways:
1517
  func any kind of function reference, no type
1736
  *E1211* *E1217* *E1218* *E1219* *E1220* *E1221*
1737
  *E1222* *E1223* *E1224* *E1225* *E1226* *E1227*
1738
  *E1228* *E1238* *E1250* *E1251* *E1252* *E1256*
1739
+ *E1297* *E1298* *E1301* *E1528* *E1529* *E1530*
1740
+ *E1531* *E1534*
1741
  Types are checked for most builtin functions to make it easier to spot
1742
  mistakes.
1743
 
1745
  *variable-categories* *null-variables*
1746
  There are categories of variables:
1747
  primitive number, float, boolean
1748
+ container string, blob, list, tuple, dict
1749
  specialized function, job, channel, user-defined-object
1750
 
1751
  When declaring a variable without an initializer, an explicit type must be
1875
  var s: string s == null
1876
  var b: blob b != null ***
1877
  var l: list<any> l != null ***
1878
+ var t: tuple<any> t != null ***
1879
  var d: dict<any> d != null ***
1880
  var f: func f == null
1881
  var j: job j == null
1886
  var s2: string = "" == null_string != null
1887
  var b2: blob = 0z == null_blob != null
1888
  var l2: list<any> = [] == null_list != null
1889
+ var t2: tuple<any> = () == null_tuple != null
1890
  var d2: dict<any> = {} == null_dict != null
1891
 
1892
  NOTE: the specialized variables, like job, default to null value and have no