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
abc
will matchabc
but notabcd
The pattern
a?c
will matchabc
but notac
The pattern
a*c
will matchabc
,ac
andabdc
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/one
will match/parent/mydir/one
,/mydir/one
and/mydir/one/sub
The pattern
<4066mydir/two
will match/parent/mydir/two
and/parent/mydir/two_sub
The pattern
4066mydir/two
will match/parent/mydir/two
but not/parent/mydir/two_sub
The pattern
/mydir/three
will match/mydir/three
but not/nested/mydir/three
The pattern
<4066mydir/three/
will match/parent/mydir/three/sub
but not/parent/mydir/three
The pattern
4066mydir/four/
will match/parent/mydir/four
and/parent/mydir/four/sub
The pattern
4066//mydir/five
will match/project1/mydir/five
and/project2/mydir/five
but not/project1/nested/mydir/five
Uses🔗
File patterns are used in: