In SublimeText3 binary_file_patterns
excludes files from being found in Files or fuzzy search (Goto Anything) while index_exclude_patterns
prevents files from being indexed.
Since we know that not indexed files cannot be found and assuming that untraceable files do not need to be indexed, what are the differences and implications by the usage of one over another?
Sublime maintains a catalog of all known files based on the folders that are currently open in the window/project, and that catalog of files is used to populate the Goto Anything
file list and also the list of files that are searched when you do Find in Files
.
You can control what appears in the catalog by using the file_exclude_patterns
and folder_exclude_patterns
settings to stop files from appearing in the sidebar (and thus in the catalog). As you mentioned you can also use binary_file_patterns
to indicate that files should still appear in the side bar, but should not be offered in the Goto Anything
panel or searched by Find in Files
.
In addition to the above, as long as index_files
is turned on, then in addition to the file catalog Sublime also runs an indexing process against the files in the side bar as well.
The indexer runs in the background using some number of threads (controlled by index_workers
) and essentially loads every file in the side bar, applies the appropriate syntax definition, and then gathers the list of symbols that are marked as ones that should appear in the index (this is a per-syntax setting). The index_exclude_patterns
setting specifies files which should not be indexed, even if they appear in the sidebar.
The index is used to power the Goto Definition
/Goto Reference
/Goto Symbol in Project
functionality; it's literally just a list of all of the indexed symbols, what files they appear in, and where in that file that they appear.
Your assumption that files that are not indexed are ones that can't be found is not correct; files that are not indexed can still appear in the side bar and be found by Goto Anything
, they just don't contribute symbols to the index, which means the above functionality will not show any content from those files, but you can still open and search them.
So overall, the implications of the two are:
If you want a file to appear in the side bar but you don't want to search inside it or have it eligible for opening with Goto Anything
, add it to the binary_file_patterns
.
If you want a file to appear in the side bar but not contribute symbols to the index, then add it to the index_exclude_patterns
setting.
Files can appear in both settings, in which case you can see them in the side bar but Sublime pretends that they're not there for purposes of all of the above functionality.