-*builtin.txt* For Vim version 9.1. Last change: 2025 Aug 12
+*builtin.txt* For Vim version 9.1. Last change: 2025 Aug 17
VIM REFERENCE MANUAL by Bram Moolenaar
(positive or negative)
islocked({expr}) Number |TRUE| if {expr} is locked
isnan({expr}) Number |TRUE| if {expr} is NaN
-items({dict}) List key-value pairs in {dict}
+items({expr}) List key-value pairs in {expr}
job_getchannel({job}) Channel get the channel handle for {job}
job_info([{job}]) Dict get information about {job}
job_setoptions({job}, {options}) none set options for {job}
Return type: |Number|
-items({dict}) *items()*
- Return a |List| with all the key-value pairs of {dict}. Each
- |List| item is a list with two items: the key of a {dict}
- entry and the value of this entry. The |List| is in arbitrary
- order. Also see |keys()| and |values()|.
- Example: >
+items({expr}) *items()*
+ Return a |List| with all the key/index and value pairs of {expr}.
+ Each |List| item is a list with two items:
+ - for a |Dict|: the key and the value
+ - for a |List|, |Tuple| or |String|: the index and the value
+ The |List| is in arbitrary order.
+
+ Also see |keys()| and |values()|.
+
+ Examples: >
+ let mydict = #{a: 'red', b: 'blue'}
for [key, value] in items(mydict)
- echo key .. ': ' .. value
+ echo $"{key} = {value}"
endfor
+ echo items([1, 2, 3])
+ echo items(('a', 'b', 'c'))
+ echo items("foobar")
<
- A |List|, a |Tuple| or a |String| argument is also supported.
- In these cases, items() returns a List with the index and the
- value at the index.
-
Can also be used as a |method|: >
mydict->items()
<
-*usr_41.txt* For Vim version 9.1. Last change: 2025 Aug 10
+*usr_41.txt* For Vim version 9.1. Last change: 2025 Aug 17
VIM USER MANUAL - by Bram Moolenaar
ngettext() lookup single/plural message translation
str2blob() convert a list of strings into a blob
blob2str() convert a blob into a list of strings
+ items() get List of List index-value pairs
List manipulation: *list-functions*
get() get an item without error for wrong index