Gei*_*erg 100 sublimetext sublimetext2 sublimetext3
对于具有许多依赖关系的大型项目,例如在node_modules/文件夹中,我注意到频繁的CPU峰值,因为Sublime索引文件夹中的所有文件.
我知道我可以使用该folder_exclude_patterns设置隐藏文件和文件夹,但我仍然希望文件夹在侧栏中可见.
我如何node_modules/在侧边栏中保留,但将其排除在索引之外?
Gei*_*erg 176
要从索引中排除文件但将其保留在侧栏中,请使用" binary_file_patterns用户设置"中的设置,例如:
"binary_file_patterns": [
"*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds",
"*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip",
"node_modules/**",
"bower_components/**"
]
Run Code Online (Sandbox Code Playgroud)
确保复制Settings - Default首选项中的值(此处显示为"*.jpg"等),否则您将开始索引二进制文件.
小智 35
您可以更改个人设置Preferences -> Settings - User,添加:
{
"folder_exclude_patterns":
[
".svn", ".git", ".hg", "CVS",
"node_modules",
],
}
Run Code Online (Sandbox Code Playgroud)
Sublime Text 3 现在提供了一种从索引中排除文件和文件夹的方法,同时将它们保留在侧边栏中:
"index_exclude_patterns": [
"*.log",
"node_modules/*"
]
Run Code Online (Sandbox Code Playgroud)
在我的项目中,我在应用更改后观察到索引状态菜单中的以下改进:
前:
index "MyApp" collated in 0.70s from 73934 files
index "MyApp" is using 15167488 bytes for 54234 symbols across 1357673 locations
Run Code Online (Sandbox Code Playgroud)
后:
index "MyApp" collated in 0.00s from 137 files
index "MyApp" is using 61440 bytes for 730 symbols across 4763 locations
Run Code Online (Sandbox Code Playgroud)
在ST3(内部版本3126)中不起作用。
您可以在边栏中显示节点模块文件夹,并在其中隐藏文件:
"file_exclude_patterns":
[
...,
"node_modules/**"
]
Run Code Online (Sandbox Code Playgroud)
如果要隐藏每个节点模块的子文件夹:
"folder_exclude_patterns":
[
"node_modules/*/**"
]
Run Code Online (Sandbox Code Playgroud)
node_modules内部的所有文件将从搜索中删除,但每个node_module子文件夹在侧栏中仍将可见。