VS Code - search for two different things in two files

Viewed 39

In VS Code how do I search for one thing in one file, while at the same time searching for a different thing in a different file?

Using the normal Find when I try to search for something in a second file it overwrites any find I am doing in a previous file.

I see that the Search functionality enables me to open a search in an editor, but this functionality doesn't seem at all useful to me.

  1. There is no obvious way to run a search on a specific file short of manually copy/pasting the file path into the advanced search options.

  2. The editor that the search results open in contains adjacent context lines, which if you have a large number of results makes it useless as a simple list of search hits.

  3. The editor that the search results open in is not editable, making it useless as an editor.

I need a list of results for each of two searches on two files.

1 Answers

Item 1 can be handled with an extension I wrote: Find and Transform. You could make a keybinding that opens the Search Panel with the current filename (or any file/folder/etc.) added to the files to include input. Actually I added a context menu command to the editor, or any editor tab or an editor in the Explorer to do just this.

Item 2. The search editor number of context lines is configurable and will remember your last setting.

Item 3. There is an extension, Search Editor: Apply Changes which can apply any changes you make in a search editor to those files.

Related