Limit File Search Scope in Sublime Text 2

2019-01-29 15:00发布

In Sublime Text, I often use Cmd+P/Ctrl+P to search and jump between files.

Often, it would pick up temporary or cached files like .scssc or things in the /tmp folder.

Is there a way that I can limit what is shown in the search result?

12条回答
太酷不给撩
2楼-- · 2019-01-29 15:12

For SublimeText 2, this is working great for me.

When you choose Find in Files, specify exclude folders in Where input;

-bower_components/**/*, -dist/**/*, -node_modules/**/*, -tmp/**/*

So, a hyphen followed by exclude pattern for folders you don't want to search in.

-folder1/**/*, -folder2/**/*

This will limit your searching scope.

See this

查看更多
SAY GOODBYE
3楼-- · 2019-01-29 15:13

For Sublime Text 3: To exclude from search and GoTo results, without removing from the sidebar, change the "binary_file_patterns" setting. Matches files AND folders.

For example, to exclude files in "dist" and "node_modules" from GoTo indexing, add this to your User Settings file:

"binary_file_patterns": ["dist/*", "node_modules/*", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds", "*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip"]

I can't figure out how to implement this on a per-project basis :(. Most settings can be moved to a project.sublime-project file. "Project > Save Project As", save it the root of your project, and add "settings": {...} to the json in the generated file. (from source, works as of ST3 build 3095). But does not work with "binary_file_patterns".

查看更多
相关推荐>>
4楼-- · 2019-01-29 15:13

This solution works perfectly for me : https://superuser.com/a/601270

Find: "something" Where: "<open folders>" // <open folders>" not include hidden folder in sidebar
查看更多
\"骚年 ilove
5楼-- · 2019-01-29 15:16

You can also exclude folders in the Find All pane by using the -*/foldername/* syntax in the Where field - eg:

-*/node_modules/*

http://www.sublimetext.com/forum/viewtopic.php?f=2&t=3847&start=10

查看更多
甜甜的少女心
6楼-- · 2019-01-29 15:20

Just note that if you want to add a subfolder of your project folder, you must to join the folders with \/. Using the same example of @DavidPärsson:

    {
        "folders":
        [
            {
                "path": "src",
                "folder_exclude_patterns": ["backup\/src\/log"]
            }
        ]
    }
查看更多
我只想做你的唯一
7楼-- · 2019-01-29 15:23

You can exclude certain file patterns and folders from your project by modifying your project settings like so:

{
    "folders":
    [
        {
            "path": "src",
            "folder_exclude_patterns": ["backup"]
        },
        {
            "path": "docs",
            "file_exclude_patterns": ["*.css"]
        }
    ]
}

This is described in the projects documentation.

查看更多
登录 后发表回答