Visual Studio Code: Search on multiple terms [duplicate]
Asked Answered
C

1

9

We are trying to figure out a way to search for all the files that contain multiple terms. For instance that reference the Orders file and then the status field. Searching for the status field alone does not work as orders have status, items have status, ...

There are two options that would fulfill the need we have for searching that I can come up with:

  1. Perform a search and then be able to search only within the results of the first search.

  2. Perform a search using the AND keyword (Orders AND status) or equivalent regular expression concept using (?=) syntax.

Visual studio code does not appear to support either of these methods. Any suggestions how to accomplish this? Thanks!

Caiaphas answered 4/8, 2017 at 14:47 Comment(1)
Related: #42179546Cupidity
P
0

1. Use regex.

Turn regex on in VSCode search by hitting the .* icon to the right of the search input.

Find files that contain the sequence term1 then term2 with anything in between:

term1((.|\n)*)term2

Find files that contain both term1 and term2 in any order:

(term1((.|\n)*)term2)|(term2((.|\n)*)term1)

Find files that contain the sequence term1 then term2 on the same line with anything in between:

term1(.*)term2

Find files that contain either term1 or term2, or both:

term1|term2

2. Search within the results of a search

The VSCode search editor allows you to copy and paste all search results. You could store the results in a new file and search within it.

There's a bunch of other neat search features in VSCode. You can read the documentation here.

Proficiency answered 22/5 at 19:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.