commit 641cb418327e52ef629aa7d41dff72ccf9bbfdcd
parent 64966ba52cea49333da076aff26866730314e259
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 25 Sep 2025 06:19:54 +0800
vim-patch:34747a1: runtime(doc): update live-grep and fuzzy-file-picker examples
closes: vim/vim#18371
https://github.com/vim/vim/commit/34747a13e08770ca871e08581551f05153dce9e2
Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
@@ -1342,12 +1342,14 @@ file picker: >
set findfunc=Find
func Find(arg, _)
- if get(s:, 'filescache', []) == []
- let s:filescache = systemlist(
- \ 'find . -path "*/.git" -prune -o -type f -print')
+ if empty(s:filescache)
+ let s:filescache = globpath('.', '**', 1, 1)
+ call filter(s:filescache, '!isdirectory(v:val)')
+ call map(s:filescache, "fnamemodify(v:val, ':.')")
endif
return a:arg == '' ? s:filescache : matchfuzzy(s:filescache, a:arg)
endfunc
+ let s:filescache = []
autocmd CmdlineEnter : let s:filescache = []
The `:Grep` command searches for lines matching a pattern and updates the
@@ -1358,8 +1360,8 @@ the `CmdlineLeavePre` autocmd from the next section): >
\ Grep call <SID>VisitFile()
func s:Grep(arglead, cmdline, cursorpos)
- let cmd = $'grep -REIHns "{a:arglead}" --exclude-dir=.git
- \ --exclude=".*"'
+ if match(&grepprg, '\$\*') == -1 | let &grepprg .= ' $*' | endif
+ let cmd = substitute(&grepprg, '\$\*', shellescape(escape(a:arglead, '\')), '')
return len(a:arglead) > 1 ? systemlist(cmd) : []
endfunc