vim-patch:63d08d4: runtime(doc): update :h write-plugin and readdir() example

1) The complete example plugin at :h write-plugin the end of the
   documentation didn't reflect the snippets provided during the
   tutorial. In most of the Add() function, interpolated strings are
   used, but the final result used concatenated strings.

2) The example provided in readdir() to get a list of files ending in
   ".txt" didn't properly escape the dot in the regular expression:
      readdir(dirname, {n -> n =~ '.txt$'})
   This would match any file ending with "txt" that is at least 4
   characters long, instead it should be:
      readdir(dirname, {n -> n =~ '\.txt$'})

closes: vim/vim#21123

63d08d4386

Co-authored-by: Josep Puigdemont <josep.puigdemont@gmail.com>
This commit is contained in:
zeertzjq
2026-08-24 08:15:34 +08:00
parent 15beb0f7ce
commit cbe513fca6
3 changed files with 3 additions and 3 deletions

View File

@@ -8277,7 +8277,7 @@ readdir({directory} [, {expr}]) *readdir()*
Each time {expr} is evaluated |v:val| is set to the entry name.
When {expr} is a function the name is passed as the argument.
For example, to get a list of files ending in ".txt": >vim
echo readdir(dirname, {n -> n =~ '.txt$'})
echo readdir(dirname, {n -> n =~ '\.txt$'})
< To skip hidden and backup files: >vim
echo readdir(dirname, {n -> n !~ '^\.\|\~$'})

View File

@@ -7425,7 +7425,7 @@ function vim.fn.readblob(fname, offset, size) end
--- Each time {expr} is evaluated |v:val| is set to the entry name.
--- When {expr} is a function the name is passed as the argument.
--- For example, to get a list of files ending in ".txt": >vim
--- echo readdir(dirname, {n -> n =~ '.txt$'})
--- echo readdir(dirname, {n -> n =~ '\.txt$'})
--- <To skip hidden and backup files: >vim
--- echo readdir(dirname, {n -> n !~ '^\.\|\~$'})
---

View File

@@ -8920,7 +8920,7 @@ M.funcs = {
Each time {expr} is evaluated |v:val| is set to the entry name.
When {expr} is a function the name is passed as the argument.
For example, to get a list of files ending in ".txt": >vim
echo readdir(dirname, {n -> n =~ '.txt$'})
echo readdir(dirname, {n -> n =~ '\.txt$'})
<To skip hidden and backup files: >vim
echo readdir(dirname, {n -> n !~ '^\.\|\~$'})