visual-studio-codeglob

VS Code Glob pattern optional single character


Using the VS Code "files to include" feature in search, I'd like to search for any Javascript file within a folder, including [.js, .ts, .jsx, .tsx] but not .json. I can already to this with 2 separate searches:

./theFolder/**/*.[tj]s, ./theFolder/**/*.[tj]sx

Is there a way to do it with just one, like it would be in Regex?

./theFolder/**/*.[tj]sx? // ? doesn't do that in vscode glob

Also see https://code.visualstudio.com/docs/editor/glob-patterns


Solution

  • At the time of this writing, there's no single-optional-character matching feature.

    But you can still make what you're doing less verbose by using {} to group conditions. Ex. ./theFolder/**/*.[jt]{s,sx}.

    For docs, in addition to https://code.visualstudio.com/docs/editor/glob-patterns, see also https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options