-
Notifications
You must be signed in to change notification settings - Fork 36k
Description
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
Example user flow
- Open Search → Advanced → Slot Builder.
- Enter literal text
I am, add a slot named name, then enter literal textfrom India. - Click Search. VS Code compiles the pattern to regex and executes it.
- The results display all lines matching that structure, highlighting the
namegroup.
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.