如何排除vimgrep中的文件模式? [英] How to exclude file patterns in vimgrep?

查看:515
本文介绍了如何排除vimgrep中的文件模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在vim中,我经常使用vimgrep进行搜索。我有如下的映射:

  map< leader> s:executenoautocmd vimgrep / \\< 。展开(< cword>)。 \\> / gj ** / *。*< Bar> 
cw< CR> 5

问题是有一些临时的子文件夹(如obj,objd),我不想要搜索。如何排除与给定模式相匹配的子文件夹。例如,前缀objd的子文件夹不应包含在搜索中。

解决方案

截至Vim 7.3.570,您可以使用wildignore可以使用vimgrep排除模式。



例如,忽略objd子文件夹:

 :set wildignore + = objd / ** 

可以通过分离添加额外的排除具有逗号的模式:

 :设置wildignore + = objd / **,obj / **,*。tmp,test.c 

有关详细信息,请参阅Vim的帮助文档。

 :help wildignore 


In vim, I do search with vimgrep frequently. I have mapping like below:

map <leader>s :execute "noautocmd vimgrep /\\<" . expand("<cword>") . "\\>/gj **/*.*" <Bar> 
cw<CR> 5

The problem is that there are some temporary subfolders (like obj, objd) that I don't want to search for. How can I exclude subfolders matching given patterns. For example, subfolders with prefix "objd" should not be included in searching.

解决方案

As of Vim 7.3.570, you can use wildignore to exclude patterns with vimgrep.

For example, to ignore the objd subfolder:

:set wildignore+=objd/**

Additional exclusions can be added by separating patterns with a comma:

:set wildignore+=objd/**,obj/**,*.tmp,test.c

See Vim's help documentation for a few more details.

:help wildignore

这篇关于如何排除vimgrep中的文件模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆