For a large project with many dependencies e.g. in the node_modules/
folder, I noticed frequent CPU spikes because of Sublime indexing all the files in the folder.
I know I can hide files and folders using the folder_exclude_patterns
setting, but I still want the folder to be visible in the sidebar.
How can I keep e.g. node_modules/
in the sidebar, but exclude it from indexing?
To exclude files from the index but keep them in the sidebar, use the binary_file_patterns
setting in your User Settings, for example:
"binary_file_patterns": [
"*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds",
"*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip",
"node_modules/**",
"bower_components/**"
]
Make sure to copy the values from your Settings - Default
preferences (here shown as "*.jpg"
etc.), or you will start indexing binary files.
You can change your personal settings, in Preferences -> Settings - User
, add:
{
"folder_exclude_patterns":
[
".svn", ".git", ".hg", "CVS",
"node_modules",
],
}
Doesn't work in ST3 (Build 3126).
You can show node modules folders in sidebar and hide files inside this way :
"file_exclude_patterns":
[
...,
"node_modules/**"
]
If you want to hide subfolders from each node module :
"folder_exclude_patterns":
[
"node_modules/*/**"
]
All files inside node_modules will be removed from search, but each node_module subfolder will be still visible in sidebar.