如何从 sublime text 3 的搜索中永久排除文件夹?
How do I exclude a folder from search in sublime text 3 permanently?
有没有办法始终忽略文件夹...在项目视图中。
我在一个存储库中有多个应用程序,每个应用程序中有 'node_modules'
mainapp
├── microapp
│ └── node_modules
├── microapp2
│ └── node_modules
├── index
├── config
└── assets
当我在上述结构中搜索项目内部时,我想从搜索中排除 node_modules
文件夹。
转到 设置 菜单并在 Preferences.sublime-settings
文件中为用户添加一个新节点到名为 folder_exclude_patterns
的 json .在其中,添加您不想显示的文件夹(以json数组格式)。
示例:
{
// ... other settings
"folder_exclude_patterns": ["node_modules", "another_folder"],
}
如果您想排除某个目录或文件而不将其隐藏在侧边栏中,您可以忽略上述解决方案和搜索栏Where
部分中的Add Exclude Filter
。但每次更改搜索目录时都必须指定它。
注意:您可能需要重新启动 Sublime Text 才能看到更改,如@Soferio 所述
如果您进入 首选项 菜单,然后进入 select 设置 ,它会打开一个 JSON所有设置及其默认值的文件。此文件还用作说明设置含义的文档。其中两个与此相关。这是设置 JSON 文件中的片段(最后在 Sublime Text 4 中验证):
// 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", ".Trash", ".Trash-*"],
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", ".directory", "desktop.ini", "*.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"],
这里说 "folder_exclude_patterns"
从 边栏 隐藏了它,而 "binary_file_patterns"
从 搜索 隐藏了它](这些“不会包含在 Goto Anything 或 Find in Files 中”)。所以如果你想从两者中排除它,你可以打开覆盖默认设置的用户设置文件,并添加以下内容。
请注意,当您转到“首选项”-->“设置”时,用户设置文件就是您在右侧窗格中看到并可以编辑的文件。
无论如何,添加以下内容:
{
"folder_exclude_patterns": ["node_modules"],
"binary_file_patterns": ["*/node_modules/*"]
}
上面两个条目是不同的,因为前者是文件夹模式,而后者是文件模式。
我在 Rails 项目上为我的中型 Ruby 添加了 "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/", "vendor/bundle/"],
以前,在文件中查找所有内容大约需要 7 秒:
Searching 28526 files for "as records_with_errors"
之后,查找所有文件不到 1 秒:
Searching 1658 files for "as records_with_errors"
我添加 coverage
不是为了性能,而是为了防止出现冗余、无用的搜索结果。
顺便说一句,我发现这个问题的大部分解决方案都集中在 folder_exclude_patterns
上,而忽略了 binary_file_patterns
可以指定文件夹模式,可能是由于它的名称和 Sublime 的默认设置.
使用 folder_exclude_patterns
不是 OP 正在寻找的干净解决方案。它从侧边栏隐藏文件夹这一事实肯定会让您在有一天您确实去寻找这些文件并且它们根本不存在时挑战您的理智。
当然,这种担忧也适用于对查找结果的抑制,在阻止过多文件夹之前应仔细权衡。只包括 folders/patterns 您主动想要禁止的内容...不要包括您认为如果不会给您带来问题就不需要搜索的内容。
这些是正确的解决方案,但您必须重新启动 Sublime3 才能使更改的配置生效。不要只是关闭 windows,退出整个应用程序。
排除 sub-folder/sub-directory "folder_exclude_patterns": ["src/file-manager"]
对我有用 windows。
有没有办法始终忽略文件夹...在项目视图中。
我在一个存储库中有多个应用程序,每个应用程序中有 'node_modules'
mainapp
├── microapp
│ └── node_modules
├── microapp2
│ └── node_modules
├── index
├── config
└── assets
当我在上述结构中搜索项目内部时,我想从搜索中排除 node_modules
文件夹。
转到 设置 菜单并在 Preferences.sublime-settings
文件中为用户添加一个新节点到名为 folder_exclude_patterns
的 json .在其中,添加您不想显示的文件夹(以json数组格式)。
示例:
{
// ... other settings
"folder_exclude_patterns": ["node_modules", "another_folder"],
}
如果您想排除某个目录或文件而不将其隐藏在侧边栏中,您可以忽略上述解决方案和搜索栏Where
部分中的Add Exclude Filter
。但每次更改搜索目录时都必须指定它。
注意:您可能需要重新启动 Sublime Text 才能看到更改,如@Soferio 所述
如果您进入 首选项 菜单,然后进入 select 设置 ,它会打开一个 JSON所有设置及其默认值的文件。此文件还用作说明设置含义的文档。其中两个与此相关。这是设置 JSON 文件中的片段(最后在 Sublime Text 4 中验证):
// 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", ".Trash", ".Trash-*"],
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", ".directory", "desktop.ini", "*.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"],
这里说 "folder_exclude_patterns"
从 边栏 隐藏了它,而 "binary_file_patterns"
从 搜索 隐藏了它](这些“不会包含在 Goto Anything 或 Find in Files 中”)。所以如果你想从两者中排除它,你可以打开覆盖默认设置的用户设置文件,并添加以下内容。
请注意,当您转到“首选项”-->“设置”时,用户设置文件就是您在右侧窗格中看到并可以编辑的文件。
无论如何,添加以下内容:
{
"folder_exclude_patterns": ["node_modules"],
"binary_file_patterns": ["*/node_modules/*"]
}
上面两个条目是不同的,因为前者是文件夹模式,而后者是文件模式。
我在 Rails 项目上为我的中型 Ruby 添加了 "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/", "vendor/bundle/"],
以前,在文件中查找所有内容大约需要 7 秒:
Searching 28526 files for "as records_with_errors"
之后,查找所有文件不到 1 秒:
Searching 1658 files for "as records_with_errors"
我添加 coverage
不是为了性能,而是为了防止出现冗余、无用的搜索结果。
顺便说一句,我发现这个问题的大部分解决方案都集中在 folder_exclude_patterns
上,而忽略了 binary_file_patterns
可以指定文件夹模式,可能是由于它的名称和 Sublime 的默认设置.
使用 folder_exclude_patterns
不是 OP 正在寻找的干净解决方案。它从侧边栏隐藏文件夹这一事实肯定会让您在有一天您确实去寻找这些文件并且它们根本不存在时挑战您的理智。
当然,这种担忧也适用于对查找结果的抑制,在阻止过多文件夹之前应仔细权衡。只包括 folders/patterns 您主动想要禁止的内容...不要包括您认为如果不会给您带来问题就不需要搜索的内容。
这些是正确的解决方案,但您必须重新启动 Sublime3 才能使更改的配置生效。不要只是关闭 windows,退出整个应用程序。
排除 sub-folder/sub-directory "folder_exclude_patterns": ["src/file-manager"]
对我有用 windows。