How can I Spotlight search exclusively in `.txt` files in `~/.` on my disk?
In terminal app using the command line, this is easy to do.

mdfind -onlyin ~ Ramanujan|grep txt


You could make a complex query and get rid of the pipe to grep, but the above should work very quickly. You could probably assemble a finder search as well with about 12 clicks if you couldn’t use the command line tools.