visual-studio 在 Visual Studio 中搜索时仅包含某些文件类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1749837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Include only certain file types when searching in Visual Studio
提问by teedyay
Often when I want to search through my code in Visual Studio, I know the thing I'm looking for is in some C# code. However, as I've used the same variable name in a JavaScript file, I have to wade through all those search results too. This gets even worse when the text I'm looking for is also used in a third-party JavaScript library that we've brought into the project: this can result in hundreds of search results.
通常,当我想在 Visual Studio 中搜索我的代码时,我知道我要查找的是一些 C# 代码。但是,由于我在 JavaScript 文件中使用了相同的变量名,因此我也必须遍历所有这些搜索结果。当我要查找的文本也用于我们引入项目的第三方 JavaScript 库时,情况会变得更糟:这可能会导致数百个搜索结果。
To compound things, our designers include HTML mock-ups of the pages in the same project, so I often find I'm hitting loads of search results in there too.
更复杂的是,我们的设计师在同一个项目中包含了页面的 HTML 模型,所以我经常发现我也在那里找到了大量的搜索结果。
I guess what I really want is to see results in my .cs, .aspx, and .ascx files, but not .js or .htm.
我想我真正想要的是在我的 .cs、.aspx 和 .ascx 文件中看到结果,而不是 .js 或 .htm。
Is there any way to do any of the following:
有没有办法做到以下几点:
- Search only in files of a particular type (search only .cs files).
- Search only in files of any of a given set of types (search only .cs, .aspx and .ascx files).
- Search in all file types except a particular type or types (search everything except .js).
- 仅搜索特定类型的文件(仅搜索 .cs 文件)。
- 仅在任何给定类型集的文件中搜索(仅搜索 .cs、.aspx 和 .ascx 文件)。
- 搜索除特定类型以外的所有文件类型(搜索除 .js 之外的所有文件)。
I suspect not, in which case is there any crafty way of working around this?
我怀疑不是,在这种情况下,有什么巧妙的方法可以解决这个问题?
采纳答案by Matthew Jones
In the Find in Files dialog (Ctrl+Shift+F), there should be a field called Find Options. You should be able to enter the extensions of fields you want to search in a field in this dialog:
在“在文件中查找”对话框 (Ctrl+Shift+F) 中,应该有一个名为“查找选项”的字段。您应该能够在此对话框的字段中输入要搜索的字段的扩展名:
*.cs; *.aspx; *.ascx;
回答by shahkalpesh
Instead of Ctrl + F, I think it is Ctrl + Shift + Fwhich gives you the choice to specify file types, you wish to look into.
而不是Ctrl + F,我认为它Ctrl + Shift + F使您可以选择指定您希望查看的文件类型。
回答by Altaf Patel


You can choose file types from default or type your own. Regular expressions available for complex search.
您可以选择默认文件类型或键入您自己的文件类型。可用于复杂搜索的正则表达式。
回答by Even Mien
回答by arviman
I like to exclude js files by using the following search:
*.a*;*.cs*;
我喜欢使用以下搜索排除 js 文件:
*.a*;*.cs*;
Most of the times, I end up searching for stuff in aspx, cs, cshtml files so this is quite helpful.
Notice how I use *.cs*instead of *.c*since the latter would select jquery custom files such as jquery.custom1234.js (which I usually use in most of my projects), of course if you don't you could just use *.c*.
大多数时候,我最终会在 aspx、cs、cshtml 文件中搜索内容,因此这非常有用。请注意我如何使用*.cs*而不是*.c*因为后者会选择 jquery 自定义文件,例如 jquery.custom1234.js(我通常在我的大多数项目中使用它),当然,如果您不这样做,您可以只使用*.c*.
回答by Mike Atlas
In the Find dialog box, go to "find options->Look at these file types".
在“查找”对话框中,转到“查找选项->查看这些文件类型”。
Type in you own string, eg, *.cs, *.aspx, *.ascx. The click the "find all" button.
输入您自己的字符串,例如,*.cs, *.aspx, *.ascx。单击“查找全部”按钮。

