3

I have a phrase, e.g. This is an example phrase, and a collection of text files (coll.d/a.txt, coll.d/b.txt, etc.), and I'm looking for the former in the latter.

The thing is, maybe my pattern is splitted over several lines of text, so plain grep isn't so simple.
I like the way C-s deals with spaces, case, the kill-ring, and so on, and look for such behaviour.

So how can I search many files with it ?


Certainly an answer is burried somewhere in documentation or manuals but rgrep, find, replace, regexp, and occur somewhat complicate the search, without even mentionning all things dired.

Nikana Reklawyks
  • 332
  • 4
  • 15
  • Over 10k files in a remote dired buffer, (* t takes a while and) M-s a C-s freezes forever before even asking for a search string. I guess that's asking too much, but I wonder if there's another way (or why it should take so much ressources). – Nikana Reklawyks Jul 02 '15 at 17:13

1 Answers1

3
  1. Mark the files in Dired (* t to mark all).

  2. Use M-s a C-s to search them. For regexp search, use M-s a C-M-s.

See the Emacs manual, nodes Misc Dired Features and Marks vs Flags.

If you need to search in a hierarchy of directories (i.e., recursively), use Dired+ and prefix key M-+ (i.e., M-+ M-s a C-s or M-+ M-s a C-M-s).

(You can also search a set of files anywhere the same way. Create a Dired buffer of arbitrary files, from anywhere, and use the same search keys.)

Drew
  • 77,472
  • 10
  • 114
  • 243