Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

Example of search

enter image description here

like image 712
NealVDV Avatar asked Nov 10 '17 11:11

NealVDV


People also ask

How do I open all files in VS Code?

VS Code provides two powerful commands to navigate in and across files with easy-to-use key bindings. Hold Ctrl and press Tab to view a list of all files open in an editor group. To open one of these files, use Tab again to pick the file you want to navigate to, then release Ctrl to open it.

How do I search all files in Visual Studio?

In Visual Studio 2022 and later, you can set Visual Studio to always keep results. Go to Tools > Options > General > Find and Replace, and select the checkbox for Keep search results by default.

How do I search everywhere in VS Code?

Visual Studio 17.2 Preview 3 introduces a brand-new All-In-One search experience that merges the existing VS Search (Ctrl + Q) and Go To (Ctrl + T) to allow you to search both your code and Visual Studio features quicker and easier than ever, all in the same place.

How can I see all the outputs in VS Code?

Go to File>Preferences>Setting and search for the Scrollback setting and increase the value to get the number of lines of output you want. This worked for me. Save this answer. Show activity on this post.


3 Answers

As stated in @Alex's comment, search.action.focusNextSearchResult is a great match for @NealVDV's use case. It can be run by pressing 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
  • Shift+F4 (search.action.focusPreviousSearchResult) cycles backward through the search results

@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. 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
like image 71
Mathieu CAROFF Avatar answered Nov 14 '22 04:11

Mathieu CAROFF


There is this VS Code extension for that: Search - Open All Results

To install it, launch VS Code Quick Open (Ctrl+P) and run

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

like image 44
Wladimir Gramacho Avatar answered Nov 14 '22 04:11

Wladimir Gramacho


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. Something like the following:

grep -l "<Icon" * | xargs code
  • grep to look for your regex pattern with -l parameter to show only the filename.
  • xargs to pass the output as the argument for code.

This way you won't have to double click all the files one-by-one.

like image 23
Gabriel Ziegler Avatar answered Nov 14 '22 02:11

Gabriel Ziegler