Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add “Slot-based” advanced search UI to compose same-line pattern searches without manual regex #273253

@Josephmaliyekal

Description

@Josephmaliyekal

Problem statement

Developers often need to locate lines that follow a similar structure but contain dynamic values
— for example: I am "Joseph" from India, where the quoted name varies across files.

Current VS Code search requires writing/maintaining regular expressions which is error-prone for many users and leads to missed matches when whitespace, quoting, or minor punctuation varies. While regex is powerful, many users want to search on structural patterns (literal tokens + variable slots) without learning regex syntax.

Proposed solution

Introduce an optional “Slot Builder” in the Search view’s Advanced panel. The builder allows users to construct searches by alternating literal tokens and variable slots. Each slot is a typed placeholder (e.g., quoted string, single word, custom regex) that maps to a pre-built regex fragment. The UI compiles the sequence into a single regex and executes it with the existing search backend (ripgrep). The implementation should:

  • Reuse the existing Search engine and settings (case sensitivity, files/include).
  • Display a live regex preview and a human-readable summary before execution.
  • Produce the same results and highlighting behavior as standard search.
  • Optionally highlight named capture groups (slot names) in the Search Editor results.

Motivation & benefits

  • Lowers the barrier for non-regex users to perform complex, same-line pattern searches
  • Reduces the chance of subtle regex errors (missing escapes, newline issues).
  • Improves discoverability of structural searching patterns relevant in logs, config files, and templates.
  • Fully backward-compatible — users can still enter raw regex as before.

Example Image

  • Image

Example user flow

  1. Open Search → Advanced → Slot Builder.
  2. Enter literal text I am, add a slot named name, then enter literal text from India.
  3. Click Search. VS Code compiles the pattern to regex and executes it.
  4. The results display all lines matching that structure, highlighting the name group.

Example Results

  • I am Joseph from India. (or it even can be I am "Joseph" from India)
  • I am XYZ from India.
  • I am !1:R from India.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions