简体   繁体   中英

Prevent Sublime Text from including .sublime-workspace files in search

Here is my Preferences.sublime-settings file:

{
    "bold_folder_labels": true,
    "highlight_line": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "remember_open_files": true,
    "folders":
    [
        {
         "file_exclude_patterns": ["*.sublime-workspace"]
        }
    ]
}

When I search all of my open files and folders in the sidebar (cmd-shift-f) I still get search results including workspace files which live in one of the directories which I have open. For instance, if I have ~/foo open and there's a file ~/foo/bar/hello.sublime-workspace , it gets included in the search results.

How do I get Sublime to never include .sublime-workspace files in my searches?

According to the comments here it looks like you have two possible solutions:

  1. Use a negated pattern in the "Where:" field of "Find in Files...": -*.sublime-workspace
  2. In your settings file in the "folders" section, add "binary_file_patterns": ["*.sublime-workspace"]

Edit

Actually, you may just need to specify a "path" for your "file_exclude_patterns" :

"folders":
[
    {
        "path": "./",
        "file_exclude_patterns": [".sublime-workspace"]
    }
]

From http://www.sublimetext.com/docs/2/projects.html :

Each folder must have a path , and may optionally have a folder_exclude_patterns and file_exclude_patterns setting.

You can add a filter by appending " ,-*.sublime-workspace " to your directory next to Where:

For example, set Where to

<project>,-*.sublime-workspace

to search all your project directories, or

c:\mydir,-*.sublime-workspace

to search a specific directory.

This answers the question title but for a problem that can come up in project-level configuration.

It's a reported bug that binary_file_patterns does not work on a per-project basis. Except it sometimes does. In any case, this worked for me when I moved the workspace exclusion, for a project, from binary_file_patterns to file_exclude_patterns.

Another issue you may be unaware of is that if you open the directory with subl . , it does not load the project. You need to go to "Sublime > Project" and "open project" for the settings to take effect. Yes, this is terrible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM