visual-studio 将搜索限制为 Visual Studio 中的指定文件夹或文件类型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/795691/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:24:53  来源:igfitidea点击:

Limit search to specified Folders or File Types in Visual Studio?

visual-studiosearchvisual-studio-2008find

提问by Bryan

Is there a way to limit a search (via the "Find and Replace" dialog) in Visual Studio to specified folders or file types?

有没有办法将 Visual Studio 中的搜索(通过“查找和替换”对话框)限制为指定的文件夹或文件类型?

回答by Fabio Vinicius Binder

Yes, in the find/replace window you can:

是的,在查找/替换窗口中,您可以:

  • specify the file types in the "Look at these file types" option
  • and choose the folders in the ...button of the "Look in" option.
  • 在“查看这些文件类型”选项中指定文件类型
  • ...在“查找范围”选项的按钮中选择文件夹。

Find and Replace Window

查找和替换窗口

回答by Wolfie

I can't believe this issue still exists in VS2015. We have a solution explorer folder tree. Why is "Current Selected Folder" not an option in the drop down. The "..." doesn't default to starting in the solution folder, I have to browse across the network to t the share, then drill down through all the folders to get at a folder that is ALREADY right there and selected in the solution explorer. Dreamweaver has had this functionality for its search for at least a decade (maybe longer).

我不敢相信这个问题在 VS2015 中仍然存在。我们有一个解决方案资源管理器文件夹树。为什么“当前选定的文件夹”不是下拉菜单中的选项。“...”并不默认从解决方案文件夹中开始,我必须通过网络浏览到共享,然后向下钻取所有文件夹以找到一个已经存在的文件夹并在解决方案浏览器。Dreamweaver 已拥有此功能用于其搜索至少十年(可能更长)。

回答by ManirajSS

  1. Click Find in Files
  2. Choose search folders three dots button "..."
  3. Choose desired folder
  4. Verify folder name and click desired action
  1. 单击在文件中查找
  2. 选择搜索文件夹三点按钮“...”
  3. 选择所需的文件夹
  4. 验证文件夹名称并单击所需的操作

Click Find in Files

单击在文件中查找

Choose search folders

选择搜索文件夹

Choose desired folderVerify folder name and click desired action

选择所需的文件夹验证文件夹名称并单击所需的操作

回答by Jpsy

Fastest folder search in VS:

VS 中最快的文件夹搜索:

As said in other answers, there is no immediate way to limit your search to a given folder within the current solution. (There are at least 3 feature requests for this in visualstudio.uservoice.comthat have all been closed for lack of upvotes.)

正如其他答案中所说,没有立即的方法将您的搜索限制在当前解决方案中的给定文件夹中。(visualstudio.uservoice.com中至少有 3 项功能请求均因缺乏投票而关闭。)

But here is the fastest workaround that I could find.
Works without leaving VS and with keystrokes only (no mouse action required):

但这是我能找到的最快的解决方法。
无需离开 VS 且仅使用按键即可工作(无需鼠标操作):

  • In Solution Explorer select the folder to search within.
  • Press Ctrl-C(copies folder path to clipboard).
  • Press Ctrl-Shift-Fto open "Find in Files".
  • Enter your search term, then press Tabto forward the cursor to the "Look in" field.
  • Press Ctrl-Vto paste in the folder path from clipboard.
  • 在解决方案资源管理器中选择要在其中搜索的文件夹。
  • Ctrl-C(将文件夹路径复制到剪贴板)。
  • Ctrl-Shift-F打开“在文件中查找”。
  • 输入您的搜索词,然后按Tab将光标移至“查找范围”字段。
  • Ctrl-V粘贴剪贴板中的文件夹路径。

回答by Wray Smallwood

While the Choose Search Folders works, it could be much better. I would really like to choose folders to exclude as well as include because sometimes folders are nested. You may want a folder but only some of the subfolders.

虽然选择搜索文件夹有效,但它可能会更好。我真的很想选择要排除和包含的文件夹,因为有时文件夹是嵌套的。您可能需要一个文件夹,但只需要一些子文件夹。

But by far the worst inconvenience is that it is not stored with the solution. If I go to the trouble of defining a search, and close VS, then reopen, I have to define it all over.

但到目前为止,最不方便的是它没有与溶液一起储存。如果我去定义搜索的麻烦,并关闭VS,然后重新打开,我必须重新定义它。