glob-patterns.md

 1# Glob Patterns
 2
 3Glob patterns are Unix shell-style wildcards for matching file paths, like `*.md` or `docs/**/*.rs`. Zed uses globs in search filters, file exclusions, and various settings.
 4
 5## Syntax Reference
 6
 7| Pattern | Matches | Example |
 8|---------|---------|---------|
 9| `?` | Any single character | `?.md` matches `a.md`, not `ab.md` |
10| `*` | Any sequence of characters (except `/`) | `*.rs` matches `main.rs`, `lib.rs` |
11| `**` | Any directory depth (including zero) | `src/**/*.rs` matches `src/main.rs`, `src/lib/utils.rs` |
12| `[abc]` | Any one character in brackets | `[abc].txt` matches `a.txt`, `b.txt`, `c.txt` |
13| `[a-z]` | Any character in range | `[0-9].log` matches `1.log`, `9.log` |
14| `[!abc]` | Any character not in brackets | `[!0-9].txt` matches `a.txt`, not `1.txt` |
15
16## Common Examples
17
18```/dev/null/examples.txt#L1-12
19# File extensions
20*.rs                    # All Rust files
21*.{rs,toml}             # NOT supported - use multiple patterns
22
23# Directory matching
24docs/**/*.md            # All Markdown files under docs/
25**/test_*.py            # Test files in any directory
26
27# Case-insensitive matching (globs are case-sensitive)
28*.[cC]                  # Matches .c and .C files
29```
30
31## Where Globs Are Used
32
33| Feature | Setting/Location | Notes |
34|---------|------------------|-------|
35| Project search | Include/Exclude filters | Filter search results by path |
36| File excludes | `file_scan_exclusions` | Hide files from project panel |
37| Search excludes | `search.exclude` | Exclude from search results |
38| Formatter overrides | `languages.*.format_on_save` | Match files for formatting rules |
39
40## Notes
41
42- Globs in Zed are **case-sensitive**. On macOS (case-insensitive filesystem), `*.c` won't match `Main.C`.
43- Brace expansion (`{a,b,c}`) is **not supported**. Use separate patterns instead.
44- Patterns are matched against the full path from the project root.
45- To match a literal `-` in brackets, place it first or last: `[-abc]` or `[abc-]`.
46- To match a literal `[` or `]`, use `[[]` or `[]]`.
47
48## See Also
49
50- [Configuring Zed](../configuring-zed.md) for settings that accept glob patterns
51- [gitignore patterns](https://git-scm.com/docs/gitignore#_pattern_format) use similar but not identical syntax