The application a file will open with is identified by the Item Kind. For example, a "Plain text document" will open with TextMate, while a "TextWrangler text document" will open with TextWrangler. The applications themselves are responsible for supplying these item kinds, and they are assigned to the files, which will then allow OS X to select the application to open them with.
You can check this info on single files with
mdls -name kMDItemKind -raw some-file.txt
So, to search for all files that will open with TextMate, search for them with that specific Item Kind:
mdfind 'kMDItemKind == "Plain text document"'
You can also restrict this search to a certain folder:
mdfind -onlyin /some/folder 'kMDItemKind == "Plain text document"'
Now, how do you find out these "Item Kind" strings that applications provide?
Go to the application file you're interested in, and right-click it. Select Show Package Contents… and navigate to Contents/Resources. Open Info.plist.
Here, you'll find the document types the application can handle, including their Document Type Name, which is exactly the one you can search for with
How can I see, and change, the application which a certain file will open?
Select the file, right-click it and click Get Info. Change the application listed under Open with:
Another useful app for maintaining default applications and associations is RCDefaultApp.