Sublime Text – exclude / include search folders using regex

I recently switched from Eclipse to Sublime Text 3 and am very happy I did. It is fast to load, lots of extensions, active community.

One thing that I couldnt figure out was how to exclude folders from the search within files (project). I mostly code in JS (Sencha Ext/Touch) and ColdFusion and keep my JSDuck API Docs etc in the same project folder as my source files. That means that when I search within files in my project I end up with matches from the docs folder, which is not what I want. Also, and probably more importantly, when using Sencha Cmd to build production apps there is a /build folder which I do not want to search in since that is the “compiled” output.

There is a forum post about using -/my/path/to/folderToExclude (ie prefix the path with a – ).

For Windows (which I use) you need backslashes instead of forward slashes and the syntax becomes odd (IMJ). At the end of that post was an example of using regex in the Where input box. This was a revelation.

So, to exclude the various folders within my project that I never want to search in, my where box looks like:


which means search in all folders and subfolders in the project except these ones. Brilliant!

By the same method you can be specific about which folder to include. eg:

*/app/* will find a match in all “app” folders (and sub folders of course) eg myappname/app and myappname/build/app. However I want the first one but not the second one (build). So:


does the trick, only searching in folder (and sub folders of) myappname/app.

And, of course you can combine exclude and include:


ie only search in myappname/app/ but NOT in myappname/app/controller (or any sub folder with ‘controller’ in the path)

Finally, dont forget that the Where box is cached and previous contents are available by clicking the down arrow at the end of the input box. So, you can easily switch between saved search strings.

All very nifty!

2 thoughts on “Sublime Text – exclude / include search folders using regex

  1. Hi —
    I’m potentially interested to use Sublime Text for CFML editing. Any tips about that? Which plugin, Reference doc. Can you share your experience? Do you use Sublime instead of CFBuilder or CFEclipse?
    Many thanks,

    • Yes, I use Sublime Text 3 for all my editing now – CF, HTML, JS. I havent yet tried a Java edit and build cycle because I use Java very infrequently. I highly recommend ST3 and it keeps getting better. It is fast (almost instant loading of a project), extendible in many ways, great snippets functionality and lots of plugins. For CF I use the package. Make sure you install the Package Control ( before installing other packages. It makes life much easier.

      One thing that throws people at first, including me, is that the interface is designed more for keyboard than mouse so there is not as much visual presentation as with other editors. However, once you learn a few of the shortcuts it becomes natural. Watch this video for a good run down of how to best use ST: IT is for ST2 but I learned so much and saved myself lots of time.

      Go well,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s