Skip to content

ranyitz/vscode-search-presets

Repository files navigation

search-presets-logo

VSCode Search Presets

vscode extension to configure search presets

Sometimes you want to search through a specific set of files, you can use vscode's search include/exclude configurations to filter the results. There are some common workflows that are repeated throughout your day, like searching only test files, only source files, only package.json files, etc. This extension lets you configure presets which configure your search by typing a single command.

search presets

Installation

Click Here

How to use it?

Use the command palette and type Search Presets Or use one of the shortcuts:

  • Windows: shift + alt + f
  • Mac: option + alt + f

How does it know what query to take?

It will resolve the query in the following order

  • A query which is configured for the preset.
  • Highlighted text in VSCode.
  • Clipboard text
  • Empty query

Unfortunatly at the moment, there is no API for reading the current query in the search widget

Extension Settings

filesToInclude

Files to include in the search

filesToExclude

Files to exclude from the search

isCaseSensitive

Match Case (Aa)

matchWholeWord

Match Whole Word (ab)

isRegex

Use Regular Expressions (.*)

triggerSearch

Trigger search after selecting a preset

query

Enforce a specific search query

Custom Preset Configuration

null means that the preset will not override the existing search configuration

"search-presets.custom": {
    [PresetName]": {
        "filesToInclude": string | null,
        "filesToExclude": string | null,
        "isCaseSensitive": boolean | null,
        "matchWholeWord": boolean | null,
        "isRegex": boolean | null,
        "triggerSearch": boolean | null,
        "query": string | null
    }
}

Global Configurations

Apply as defaults for all preset configurations

"search-presets.isCaseSensitive": boolean | null,
"search-presets.matchWholeWord": boolean | null,
"search-presets.isRegex": boolean | null,
"search-presets.triggerSearch": boolean | null

Default presets

If you don't configure anything, this are the presets you'll get

"search-presets.custom": {
    "Tests": {
      "filesToInclude": ".test.*, .spec.*, .e2e.*, .driver.*"
    },
    "Source Files": {
      "filesToExclude": "*.test.js, *.driver.*, *.json"
    },
    "package.json": {
        "filesToInclude": "package.json"
    }
}