summaryrefslogtreecommitdiff
path: root/runtime/doc/eval.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-26 20:41:29 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-26 20:41:29 +0100
commit74e54fcb447e5db32f9c2df34c0554bbecdccca2 (patch)
tree09448c671db2b150c1af1575c239cddf2772272e /runtime/doc/eval.txt
parent522eefd9a247c574a51bfe9bf73467a8dc3bac42 (diff)
downloadvim-git-74e54fcb447e5db32f9c2df34c0554bbecdccca2.tar.gz
patch 8.2.2658: :for cannot loop over a stringv8.2.2658
Problem: :for cannot loop over a string. Solution: Accept a string argument and iterate over its characters.
Diffstat (limited to 'runtime/doc/eval.txt')
-rw-r--r--runtime/doc/eval.txt14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 86df7b570..428cb08e5 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -439,8 +439,8 @@ Changing the order of items in a list: >
For loop ~
-The |:for| loop executes commands for each item in a list. A variable is set
-to each item in the list in sequence. Example: >
+The |:for| loop executes commands for each item in a List, String or Blob.
+A variable is set to each item in sequence. Example with a List: >
:for item in mylist
: call Doit(item)
:endfor
@@ -457,7 +457,7 @@ If all you want to do is modify each item in the list then the |map()|
function will be a simpler method than a for loop.
Just like the |:let| command, |:for| also accepts a list of variables. This
-requires the argument to be a list of lists. >
+requires the argument to be a List of Lists. >
:for [lnum, col] in [[1, 3], [2, 8], [3, 0]]
: call Doit(lnum, col)
:endfor
@@ -473,6 +473,14 @@ It is also possible to put remaining items in a List variable: >
: endif
:endfor
+For a Blob one byte at a time is used.
+
+For a String one character, including any composing characters, is used as a
+String. Example: >
+ for c in text
+ echo 'This character is ' .. c
+ endfor
+
List functions ~
*E714*