nol*_*awi 49 search text-editor editor sublimetext sublimetext3
是否有办法在项目视图中始终忽略文件夹...
我在一个仓库中有多个应用程序,每个应用程序都有"node_modules"
mainapp
---microapp
-----node_modules
---microapp2
-----node_modules
---index
---config
---assets
Run Code Online (Sandbox Code Playgroud)
node_modules当我在上面的结构中搜索项目时,我想从搜索文件夹中排除.
SUB*_*0DH 63
转到" 设置"菜单和Preferences.sublime-settings用户的文件,并将新节点添加到名为的json folder_exclude_patterns.在其中,添加您不想显示的文件夹(以json数组格式).
例:
{
// ... other settings
"folder_exclude_patterns": ["node_modules", "another_folder"],
}
Run Code Online (Sandbox Code Playgroud)
如果要排除某些目录或文件而不将其从侧栏中隐藏,则可以忽略上述解决方案并Add Exclude Filter在Where搜索栏的部分中.但是每次更改搜索目录时都必须指定它.
Ale*_*air 31
如果您转到"首选项"菜单然后选择"设置",它将打开包含所有设置及其默认值的JSON文件.此文件还可用作设置含义的文档.其中两个在这里是相关的.这是JSON文件的片段;
// folder_exclude_patterns and file_exclude_patterns control which files
// are listed in folders on the side bar. These can also be set on a per-
// project basis.
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS"],
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.class", "*.psd", "*.db", "*.sublime-workspace"],
// These files will still show up in the side bar, but won't be included in
// Goto Anything or Find in Files
"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"],
Run Code Online (Sandbox Code Playgroud)
它在这里folder_exclude_patterns说它从侧栏binary_file_patterns隐藏它,同时隐藏它从搜索.因此,如果要将它们从两者中排除,可以打开"用户设置"文件(它会覆盖默认设置)并添加;
{
"folder_exclude_patterns": ["node_modules"],
"binary_file_patterns": ["*/node_modules/*"]
}
Run Code Online (Sandbox Code Playgroud)
请注意,两者是不同的,因为前者是文件夹模式,而后者是文件模式.
小智 9
要从 Sublime 的全局文件夹搜索中排除任何特定文件 ( package.json ) 或任何文件类型 ( .scss ) 或任何子文件夹 ( node_modules 、 assets ),您可以使用以下表示法:
E:\X-Author-GDocs-UI, -*/node_modules/*, -*/assets/*, -*.scss, -package.json
Run Code Online (Sandbox Code Playgroud)
我为中等大小的Ruby on Rails项目添加"node_modules/", "coverage/", "tmp/cache/"了binary_file_patterns,以加快痛苦的搜索速度:
"binary_file_patterns": ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds",
"*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip",
"node_modules/", "coverage/", "tmp/cache/"],
Run Code Online (Sandbox Code Playgroud)
之前,“查找所有文件”耗时约7秒钟:
Searching 28526 files for "as records_with_errors"
Run Code Online (Sandbox Code Playgroud)
之后,“查找所有文件”将花费不到1秒的时间:
Searching 1658 files for "as records_with_errors"
Run Code Online (Sandbox Code Playgroud)
我coverage并不是为了提高性能,而是为了防止多余的,无用的搜索结果。
顺便说一句,我发现的大多数解决方案都针对folder_exclude_patterns,而忽略了binary_file_patterns可以指定文件夹模式的原因,这可能是由于其名称和Sublime的默认设置所致。
folder_exclude_patterns对于OP来说,使用不是一个干净的解决方案。它从侧边栏隐藏文件夹的事实一定会让您挑战自己的理智,因为总有一天您会去寻找那些文件,而这些文件根本不存在。
当然,这种担忧也适用于抑制“查找”结果,应该在阻止太多文件夹之前仔细权衡一下。只包括您要积极抑制的文件夹/模式...不要包括您认为根本不会造成问题的简单搜索内容。