有没有一种简单的方法来排除 FuzzyFinder 搜索的文件?

发布于 2024-10-01 20:40:00 字数 146 浏览 9 评论 0原文

我正在使用 FuzzyFinder,并且想知道如何指示 FuzzyFinder 排除它搜索的文件。现在我已经修改了插件代码,但必须有一个更简单的方法。

我想排除 .class 文件在结果中弹出。有关如何指示 FuzzyFinder 跳过这些文件的任何提示/技巧?

I am using FuzzyFinder and was wondering how I could instruct FuzzyFinder to exclude files it searches for. For now I have modified the plugin code but there must be a more easy way.

I want to exclude .class files from popping up in the result. Any hints/tips on how can I instruct FuzzyFinder to skip these files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千纸鹤带着心事 2024-10-08 20:40:00
let g:fuf_file_exclude = '\v\~$|\.o$|\.exe$|\.bak$|\.swp$|\.class

使用 :help fuf-options 了解更多详细信息。

使用 :help fuf-options 了解更多详细信息。

let g:fuf_file_exclude = '\v\~$|\.o$|\.exe$|\.bak$|\.swp$|\.class

Use :help fuf-options for more details.

Use :help fuf-options for more details.

溺渁∝ 2024-10-08 20:40:00

在伯努瓦的帮助下:

"FuzzyFinder should ignore all files in .gitignore
let ignorefile = ".gitignore"
if filereadable(ignorefile)

  let ignore = '\v\~

  for line in readfile(ignorefile)
    let line = substitute(line, '\.', '\\.', 'g')
    let line = substitute(line, '\*', '.*', 'g')
    let ignore .= '|^' . line
  endfor

  let g:fuf_coveragefile_exclude = ignore
endif

With the help of Benoit:

"FuzzyFinder should ignore all files in .gitignore
let ignorefile = ".gitignore"
if filereadable(ignorefile)

  let ignore = '\v\~

  for line in readfile(ignorefile)
    let line = substitute(line, '\.', '\\.', 'g')
    let line = substitute(line, '\*', '.*', 'g')
    let ignore .= '|^' . line
  endfor

  let g:fuf_coveragefile_exclude = ignore
endif
天生の放荡 2024-10-08 20:40:00

这是最自动的解决方案,可在具有自己的 lcd(本地当前目录)的不同窗口和选项卡中工作。

由于 Vimrc 没有每个窗口或每个选项卡设置排除变量的概念,因此您必须在每次运行 FufFile 或相关函数时重置排除变量。

将其放入您的 .vimrc 中:

" FuzzyFinder
" -----------------------------------------------------------------------------
function! FufSetIgnore()

    let ignorefiles = [ $HOME . "/.gitignore", ".gitignore" ]
    let exclude_vcs = '\.(hg|git|bzr|svn|cvs)'
    let ignore = '\v\~


    for ignorefile in ignorefiles

        if filereadable(ignorefile)
            for line in readfile(ignorefile)
                if match(line, '^\s*
) == -1 && match(line, '^#') == -1
                    let line = substitute(line, '^/', '', '')
                    let line = substitute(line, '\.', '\\.', 'g')
                    let line = substitute(line, '\*', '.*', 'g')
                    let ignore .= '|^' . line
                endif
            endfor
        endif

        let ignore .= '|^' . exclude_vcs
        let g:fuf_coveragefile_exclude = ignore
        let g:fuf_file_exclude = ignore
        let g:fuf_dir_exclude = ignore

    endfor
endfunction

# Bonus: My custom key mappings for FuzzyFinder
# Calls the function to set the exclude variables, then runs FuzzyFinder
nn <Tab>   :call FufSetIgnore() <BAR> :FufFile<CR>
nn <S-Tab> :call FufSetIgnore() <BAR> :FufFile **/<CR>
nn <F3>    :call FufSetIgnore() <BAR> :FufFile **/<CR>

This is the most automatic solution that will work in different windows and tabs that have their own lcd (local current directory).

Since Vimrc doensn't have the concept of setting exclude variables per-window or per-tab, you have to reset the exclude variables each time your run FufFile or related functions.

Put this in your .vimrc:

" FuzzyFinder
" -----------------------------------------------------------------------------
function! FufSetIgnore()

    let ignorefiles = [ $HOME . "/.gitignore", ".gitignore" ]
    let exclude_vcs = '\.(hg|git|bzr|svn|cvs)'
    let ignore = '\v\~


    for ignorefile in ignorefiles

        if filereadable(ignorefile)
            for line in readfile(ignorefile)
                if match(line, '^\s*
) == -1 && match(line, '^#') == -1
                    let line = substitute(line, '^/', '', '')
                    let line = substitute(line, '\.', '\\.', 'g')
                    let line = substitute(line, '\*', '.*', 'g')
                    let ignore .= '|^' . line
                endif
            endfor
        endif

        let ignore .= '|^' . exclude_vcs
        let g:fuf_coveragefile_exclude = ignore
        let g:fuf_file_exclude = ignore
        let g:fuf_dir_exclude = ignore

    endfor
endfunction

# Bonus: My custom key mappings for FuzzyFinder
# Calls the function to set the exclude variables, then runs FuzzyFinder
nn <Tab>   :call FufSetIgnore() <BAR> :FufFile<CR>
nn <S-Tab> :call FufSetIgnore() <BAR> :FufFile **/<CR>
nn <F3>    :call FufSetIgnore() <BAR> :FufFile **/<CR>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文