简体   繁体   English

在 VScode 中打开搜索结果中存在的所有文件

[英]Open all files present in search result in VScode

Is it anyway possible to open all files which found in my search query?是否可以打开在我的搜索查询中找到的所有文件? Otherwise I need to double click 37 times for a single search result which seems suboptimal.否则,我需要双击 37 次才能获得似乎次优的单个搜索结果。

Example of search搜索示例

在此处输入图像描述

There is this VS Code extension for that: Search - Open All Results有这个 VS Code 扩展: 搜索 - 打开所有结果

To install it, launch VS Code Quick Open (Ctrl+P) and run要安装它,请启动 VS Code Quick Open (Ctrl+P) 并运行

ext install fabiospampinato.vscode-search-open-all-results

As stated in @Alex's comment, search.action.focusNextSearchResult is a great match for @NealVDV's use case.正如@Alex 的评论中所述, search.action.focusNextSearchResult非常适合@NealVDV 的用例。 It can be run by pressing F4 .它可以通过F4运行。 It will open each result one after the other in a (writable) preview tab.它将在(可写)预览选项卡中一个接一个地打开每个结果。

  • F4 ( search.action.focusPreviousSearchResult ) cycles forward through the search results F4 ( search.action.focusPreviousSearchResult ) 在搜索结果中向前循环
  • Shift+F4 ( search.action.focusPreviousSearchResult ) cycles backward through the search results Shift+F4 ( search.action.focusPreviousSearchResult ) 在搜索结果中向后循环

@jakub.g makes the remark that modifying a file in a way that removes them from the search result will make the focusNextSearchResult pointer restart from the beginning. @jakub.g 表示以将文件从搜索结果中删除的方式修改文件将使focusNextSearchResult指针从头开始重新启动。 A solution to this issue is to make sure that either:此问题的解决方案是确保:

  • The search result is never removed from the file while it is modified搜索结果在修改时永远不会从文件中删除
  • The search result is always removed from the file by the modification搜索结果总是通过修改从文件中删除

I'm not sure how to do this with a VSCode native tool, but you could do this using VSCode terminal to find the pattern that you're looking for and open all files that match your search pattern.我不确定如何使用 VSCode 本机工具执行此操作,但是您可以使用 VSCode 终端来查找您要查找的模式并打开与您的搜索模式匹配的所有文件。 Something like the following:类似于以下内容:

grep -l "<Icon" * | xargs code
  • grep to look for your regex pattern with -l parameter to show only the filename. grep 使用-l 参数查找您的正则表达式模式以仅显示文件名。
  • xargs to pass the output as the argument for code . xargs将输出作为code的参数传递。

This way you won't have to double click all the files one-by-one.这样您就不必一一双击所有文件。

Turns out you can shift + click to highlight all the results, and then you drag them over same as any other file.事实证明,您可以移动 + 单击以突出显示所有结果,然后将它们拖动到与任何其他文件相同的位置。 In vscode 1.71.2, at least.至少在 vscode 1.71.2 中。

I had 150 to open.我有150个要打开。 Phew.呸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM