Back to tips
Select All Regex Matches
Create multiple cursors on all regex pattern matches instantly
#regex
#multicursor
#search
Beyond the standard “select all matches” feature, Zed allows you to create multiple selections based on regex patterns, enabling powerful bulk editing workflows.
Here’s how to use it:
- Open buffer search with
Cmd-F(macOS) orCtrl-F(Linux/Windows) - Enable the regex search filter by clicking the
.*icon or pressingAlt-R - Enter your regex pattern (e.g.,
function\s+\w+to match function names) - Instead of pressing
Enterto navigate through matches, pressAlt-Enter
This creates a cursor at each match, allowing you to edit all occurrences simultaneously.
For example, you could:
- Match all function declarations and add JSDoc comments
- Find all hex colors (
#[0-9a-fA-F]{6}) and convert them to RGB - Select all import statements matching a pattern and update them
This is significantly more powerful than simple text matching, as you can use regex capture groups and complex patterns to target exactly what you need to edit.