runtime(doc): update live-grep and fuzzy-file-picker examples

closes: #18371

Signed-off-by: Konfekt <Konfekt@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Konfekt
2025-09-23 19:53:37 +00:00
committed by Christian Brabandt
parent 11bde1f169
commit 34747a13e0

View File

@ -1,4 +1,4 @@
*cmdline.txt* For Vim version 9.1. Last change: 2025 Sep 15 *cmdline.txt* For Vim version 9.1. Last change: 2025 Sep 23
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -1425,12 +1425,14 @@ file picker: >
set findfunc=Find set findfunc=Find
func Find(arg, _) func Find(arg, _)
if get(s:, 'filescache', []) == [] if empty(s:filescache)
let s:filescache = systemlist( let s:filescache = globpath('.', '**', 1, 1)
\ 'find . -path "*/.git" -prune -o -type f -print') call filter(s:filescache, '!isdirectory(v:val)')
call map(s:filescache, "fnamemodify(v:val, ':.')")
endif endif
return a:arg == '' ? s:filescache : matchfuzzy(s:filescache, a:arg) return a:arg == '' ? s:filescache : matchfuzzy(s:filescache, a:arg)
endfunc endfunc
let s:filescache = []
autocmd CmdlineEnter : let s:filescache = [] autocmd CmdlineEnter : let s:filescache = []
The `:Grep` command searches for lines matching a pattern and updates the The `:Grep` command searches for lines matching a pattern and updates the
@ -1441,8 +1443,8 @@ the `CmdlineLeavePre` autocmd from the next section): >
\ Grep call <SID>VisitFile() \ Grep call <SID>VisitFile()
func s:Grep(arglead, cmdline, cursorpos) func s:Grep(arglead, cmdline, cursorpos)
let cmd = $'grep -REIHns "{a:arglead}" --exclude-dir=.git if match(&grepprg, '\$\*') == -1 | let &grepprg .= ' $*' | endif
\ --exclude=".*"' let cmd = substitute(&grepprg, '\$\*', shellescape(escape(a:arglead, '\')), '')
return len(a:arglead) > 1 ? systemlist(cmd) : [] return len(a:arglead) > 1 ? systemlist(cmd) : []
endfunc endfunc