File Patterns
Ver:
Various features in Sublime Text use file patterns. These patterns are used to match against file/directory names and paths. They are similar in functionality to shell glob patterns, but have some unique behavior.
Basic Syntax🔗
File patterns allow two matching operators:
*: matches zero or more characters, except/?: matches exactly one character, except/
Neither character classes, [abc], nor the globstar operator, **, from Bash are supported.
Examples🔗
The pattern
abcwill matchabcbut notabcdThe pattern
a?cwill matchabcbut notacThe pattern
a*cwill matchabc,acandabdc
Path Rules🔗
When / is not present in a pattern, it is only compared against the file
or directory name and only the basic syntax applies. When a / is included
in a pattern, it changes the behavior to:
The pattern is matched against the entire file or directory path
In a
*/prefix or/*suffix, the*will match/characters*/will be implicitly prefixed if the pattern does not start with a/or*
<4066*will be implicitly suffixed if the pattern does not start with a/or*If the pattern ends in
/it will be treated as a directory pattern, and will match both a directory with that name and 4066 any contained files or subdirectoriesIf a pattern begins with a single
/, it will be compared as an absolute pathIf pattern begins with
4066//, it will be compared as a relative path from the project root
Examples🔗
The pattern
mydir/onewill match/parent/mydir/one,/mydir/oneand/mydir/one/subThe pattern
<4066mydir/twowill match/parent/mydir/twoand/parent/mydir/two_subThe pattern
4066mydir/twowill match/parent/mydir/twobut not/parent/mydir/two_subThe pattern
/mydir/threewill match/mydir/threebut not/nested/mydir/threeThe pattern
<4066mydir/three/will match/parent/mydir/three/subbut not/parent/mydir/threeThe pattern
4066mydir/four/will match/parent/mydir/fourand/parent/mydir/four/subThe pattern
4066//mydir/fivewill match/project1/mydir/fiveand/project2/mydir/fivebut not/project1/nested/mydir/five
Uses🔗
File patterns are used in: