Search code examples
sublimetext3

How to ignore a folder in definition index for Sublime Text 3?


Sublime Text added a new feature to show function definition.

Sublime text definition behavior

Do you know how to disable "dist" folder from the index?


Solution

  • There is a setting called index_exclude_patterns which can be used to exclude specific file patterns from the index. The default value of this is:

    // index_exclude_patterns indicate which files won't be indexed.
    "index_exclude_patterns": ["*.log"],
    

    However it seems this can only specify file patterns, not directory patterns. So things like "dist", "dist*", "dist/" or "dist/*" do not work.

    In this case a workaround is to amend the binary_file_patterns setting. The default for this is:

    // 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"],
    

    Files that are binary are not indexed and so won't show up in the definition list.

    Adding "dist/*" to the list of patterns should fix the problem up for you. Note that if you don't already have a custom setting for this you should probably copy the default first, otherwise things like images won't be considered binary any longer.