runtime(doc): update :h write-plugin and readdir() example
Commit:
https://github.com/vim/vim/commit/63d08d43862ed195da78cfb1bebe2c0ed02f80b7
Author: Josep Puigdemont <
josep.pu...@gmail.com>
Date: Sun Aug 23 19:40:54 2026 +0000
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: #21123
Signed-off-by: Josep Puigdemont <
josep.pu...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 0228bcbd6..f38a06657 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -8798,7 +8798,7 @@ readdir({directory} [, {expr} [, {dict}]]) *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": >
- readdir(dirname, {n -> n =~ '.txt$'})
+ readdir(dirname, {n -> n =~ '\.txt$'})
< To skip hidden and backup files: >
readdir(dirname, {n -> n !~ '^\.\|\~$'})
< *E857*
diff --git a/runtime/doc/usr_51.txt b/runtime/doc/usr_51.txt
index e8fb68bce..2db3dd018 100644
--- a/runtime/doc/usr_51.txt
+++ b/runtime/doc/usr_51.txt
@@ -1,4 +1,4 @@
-*usr_51.txt* For Vim version 9.2. Last change: 2026 Jun 03
+*usr_51.txt* For Vim version 9.2. Last change: 2026 Aug 23
VIM USER MANUAL by Bram Moolenaar
@@ -346,8 +346,8 @@ Here is the resulting complete example: >
26 noremap <SID>Add :call <SID>Add(expand("<cword>"), true)<CR>
27
28 def Add(from: string, correct: bool)
- 29 var to = input("type the correction for " .. from .. ": ")
- 30 exe ":iabbrev " .. from .. " " .. to
+ 29 var to = input($"type the correction for {from}: ")
+ 30 exe $":iabbrev {from} {to}"
31 if correct | exe "normal viws\<C-R>\" " | endif
32 count += 1
33 echo "you now have " .. count .. " corrections"