是否可以grep Vim的quickfix? [英] Is it possible to grep Vim's quickfix?
问题描述
1 first_file.rb | 1 col 1 |禁用某些东西
2 second_file.rb | 1 col 2 |禁用另一个东西
是否可以选择quickfix结果作为输入,grep通过它并打开结果新的quickfix?因此,如果我输入:quickfix_grep first_file
,新的quickfix将只弹出一个条目:
1 first_file.rb | 1 col 1 |禁用某些东西
更新
一个vim插件已经被写入这个需求: https://github.com/ sk1418 / QFGrep
原始答案:
我对你的目标的理解是:
你的quickfix的grep结果是某种程度上巨大的,你想缩小
你的视图的。通过使用正则表达式输入命令,过滤grep
结果。过滤后的结果也应显示在QuickFix
窗口中,以便您可以打开/跳转到该文件。
如果上面是你想要的,看看下面的内容:
源码这个函数和命令行:
功能! GrepQuickFix(pat)
如果bufname(d ['bufnr'])!〜a:pat&& amp;< (all,d))
endif
endfor
调用setqflist(全部)
endfunction
命令! -nargs = * GrepQF调用GrepQuickFix(< q-args>)
然后在grep / ack /无论在quickfix中显示什么内容,都可以输入
:GrepQF< regex>
可以在quickfix中进行过滤。
在这里我添加一个GIF动画。我正在使用 Ack
而不是 grep
,但它没有区别。给定的正则表达式将匹配文件名和quickfix中显示的文本。我过滤了两次以表明这一点。
希望它有帮助。
So let's say I use ag.vim to search 'disabled' through files. It returns me some results in quickfix window:
1 first_file.rb|1 col 1| disabled something something
2 second_file.rb|1 col 2| disabled another something
Is it possible to pick quickfix results as an input, grep through it and open results in new quickfix? So, if i would enter :quickfix_grep first_file
, new quickfix would pop up with only 1 entry:
1 first_file.rb|1 col 1| disabled something something
Update
A vim plugin has been written for this requirement: https://github.com/sk1418/QFGrep
Original Answer:
My understanding of your goal is:
Your grep result is somehow huge in your quickfix, you want to narrow your view of it. by entering a command with regex, filter the grep result. The filtered result should also be displayed in QuickFix window, so that you could open/jump to the file.
If the above is what you want, check out the following:
source this function and the command line:
function! GrepQuickFix(pat)
let all = getqflist()
for d in all
if bufname(d['bufnr']) !~ a:pat && d['text'] !~ a:pat
call remove(all, index(all,d))
endif
endfor
call setqflist(all)
endfunction
command! -nargs=* GrepQF call GrepQuickFix(<q-args>)
then after your grep/ack/whatever show stuffs in your quickfix, you could type
:GrepQF <regex>
to do filtering in your quickfix.
Here I add an GIF animation. I am using Ack
instead of grep
, but it makes no difference. The given regex will match filename and the text showing in quickfix. I did filtering twice to show that.
hope it helps.
这篇关于是否可以grep Vim的quickfix?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!