Sublime Forum

Regex for folder_exclude_patterns setting

#1

In my project I have the folders

engine/
    templates/
    temp/
    run.py
    [etc]

And I’m looking to ignore just engine/temp.

When I add just engine/temp to folder_exclude_patterns, it also matches and excludes engine/templates/ as well as engine/temp/

How can I get it to match temp/ exactly? I’ve tried using regex like “frontend/temp$” and the like to match just that, but that just results in nothing matching.

What am I missing here?

0 Likes

#2

I don’t believe there’s a way to do this currently. According to this SO answer, full regex is not supported in the exclude patterns, only wildcards (*). Additionally, my own testing revels that paths that begin or end with a slash are not supported.

I’ve opened a topic on the Sublime Issue tracker to request better path support. Issue 332. I recommend adding a comment there to increase its visibility to the Sublime devs.

I kinda doubt we’ll ever see full regex support, due to performance concerns, but I hope we’ll eventually get something better than what we have now.

In the meantime, one workaround is to use folder_include_patterns instead. Given your particular example, you could do something like the following. It’s is not very elegant, and would need to be updated manually when you add new top-level folders, but it’d work.

"folder_include_patterns":

  "engine",
  "engine/templates",
  "engine/etc",
  "other_folder",
  "other_folder/*",
  "etc"
]
0 Likes