rami300
rami300

Reputation: 69

how to limit search to certain folder AND certain file types (more than one) in visual studio code?

consider the following files and folders structure:

  head.html
  folder1
      1.css (this file is inside "folder1")
      1.html
      1.php
  folder2
      1.css
      1.html
      1.php
      subfolder2 (this is a subfolder inside "folder2")
          1.css
          1.html
          1.php
          deepsub2 (a folder inside "subfolder2" that is inside "folder2")
              1.css
              1.html
              1.php

to clarify the structure:

What i'm trying to do is search the word "viewport" in "folder2" and anything beneath it (including its subfolders), which means I don't want search in other folders (folder1 for example) or the root (head.html for example)

I also want to limit the search for file types: .html and .css

I DON'T want to specifically exclude .php as a file type because consider that sometimes I don't know what other file types there are in the structure and they can be t0o many to exclude, so I want to only to use a list of file types to include rather.

after reading the docs: https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options

the best I could come up with is using the following in the "files to include" input:

./folder2/**/*.css,./folder2/**/*.html

but it doesn't seem efficiant enough because i'm using the "folder2" path part for every file type. is there a better way?

I'm using VScode Version: 1.65.0 by the way

Upvotes: 0

Views: 602

Answers (1)

Mark
Mark

Reputation: 180659

This should work:

./folder2/**/*.{css,html} NO spaces in the {...} extensions or it won't work

from https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options:

{} to group conditions (for example {**/*.html,**/*.txt} matches all HTML and text files)

Upvotes: 2

Related Questions