Include only certain file types when searching in

2019-01-22 05:03发布

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.

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.

I guess what I really want is to see results in my .cs, .aspx, and .ascx files, but not .js or .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).

I suspect not, in which case is there any crafty way of working around this?

6条回答
爷、活的狠高调
2楼-- · 2019-01-22 05:34

In the Find in Files dialog, 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:

*.cs; *.aspx; *.ascx; 
查看更多
混吃等死
3楼-- · 2019-01-22 05:38

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.

查看更多
劫难
4楼-- · 2019-01-22 05:40

enter image description here

You can choose file types from default or type your own. Regular expressions available for complex search.

查看更多
5楼-- · 2019-01-22 05:40

Another way to limit file searches is by only choosing certain folder sets.

Setting folder sets for search

查看更多
放我归山
6楼-- · 2019-01-22 05:48

Instead of Ctrl + F, I think it is Ctrl + Shift + F which gives you the choice to specify file types, you wish to look into.

查看更多
\"骚年 ilove
7楼-- · 2019-01-22 05:52

I like to exclude js files by using the following search: *.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*.

查看更多
登录 后发表回答