How does Project Find work?


The search and replace fields are pretty obvious, but what about the third field? Well, I can enter a top-level directory name, I guess. I can also enter a file wildcard, I guess. But what about more complex things?

  • If I enter foo, will that find only the top-level directory with this name, or will it also find, say, mumble/a/lot/foo?
  • What else besides * is possible in wildcards? Will *.[hc] find C header and source files? Does ? work?
  • Can I combine criteria? I believe I have tried things like mumble, *.php to find all PHP files in the top-level directory named mumble, but that wasn’t so successful.

I’m sorry to be asking now, I guess once 1.0 comes out it will be well documented. But I hit that every time I use Atom and it slows me down…


You can always look at the source for the find-and-replace package too :grinning:


Aye. So I’ve now done that and I see that the text box contains a comma-separated list of glob patterns. They are passed to atom.workspace.scan. Which documents them thusly:

An Array of glob patterns to search within

Hm. Hmm. Hmmmmm. Hm.


Thanks! I was running out the door so I couldn’t be any more helpful than that. But … now that I’m back home …

I ran a test of various globs and this is what I came up with:

  • *.md matched all Markdown files in the tree
  • **/*.md matched all Markdown files in the tree
  • foo/**/*.md matched all Markdown files underneath the foo directory
  • *[xy].md matched all Markdown files that ended in either x or y anywhere in the tree
  • etc

So it would appear that it supports advanced file globs (almost certainly minimatch), but also if there isn’t any directory structure specified then it will match any file in the entire tree that matches the glob.


And you can use ! at the start of a path for negation, i.e.: !foo/**/*.md will search all files, except for files with the .md extension inside the foo directory.


Oooh, nice! I had been wondering how to do that.

So at work, I’ll be using patterns of the type foo/**/*.md and at home I will be using !*.htm.


I’d love to know how to search for a string like ‘join’ for example on any file in which path there appears the word ‘workspace’. So it would match all the following:

  • ‘app/js/workspaces/foo.js’
  • ‘css/project_a/some-workspace-awesome-/bar.js’
  • ‘scripts/open-workspaces/sh’