21.11.6 Searching and Replacing with Tags Tables
The commands in this section visit and search all the files listed in
the selected tags table, one by one. For these commands, the tags
table serves only to specify a sequence of files to search. A related
command is `M-x grep' (Note: Compilation).
`M-x tags-search <RET> REGEXP <RET>'
Search for REGEXP through the files in the selected tags table.
`M-x tags-query-replace <RET> REGEXP <RET> REPLACEMENT <RET>'
Perform a `query-replace-regexp' on each file in the selected tags
Restart one of the commands above, from the current location of
`M-x tags-search' reads a regexp using the minibuffer, then searches
for matches in all the files in the selected tags table, one file at a
time. It displays the name of the file being searched so you can
follow its progress. As soon as it finds an occurrence, `tags-search'
Having found one match, you probably want to find all the rest. To
find one more match, type `M-,' (`tags-loop-continue') to resume the
`tags-search'. This searches the rest of the current buffer, followed
by the remaining files of the tags table.
`M-x tags-query-replace' performs a single `query-replace-regexp'
through all the files in the tags table. It reads a regexp to search
for and a string to replace with, just like ordinary `M-x
query-replace-regexp'. It searches much like `M-x tags-search', but
repeatedly, processing matches according to your input. Note:
Replace, for more information on query replace.
It is possible to get through all the files in the tags table with a
single invocation of `M-x tags-query-replace'. But often it is useful
to exit temporarily, which you can do with any input event that has no
special query replace meaning. You can resume the query replace
subsequently by typing `M-,'; this command resumes the last tags search
or replace command that you did.
The commands in this section carry out much broader searches than the
`find-tag' family. The `find-tag' commands search only for definitions
of tags that match your substring or regexp. The commands
`tags-search' and `tags-query-replace' find every occurrence of the
regexp, as ordinary search commands and replace commands do in the
These commands create buffers only temporarily for the files that
they have to search (those which are not already visited in Emacs
buffers). Buffers in which no match is found are quickly killed; the
others continue to exist.
It may have struck you that `tags-search' is a lot like `grep'. You
can also run `grep' itself as an inferior of Emacs and have Emacs show
you the matching lines one by one. This works much like running a
compilation; finding the source locations of the `grep' matches works
like finding the compilation errors. Note: Compilation.
If you wish to process all the files in a selected tags table, but
`M-x tags-search' and `M-x tags-query-replace' are not giving you the
desired result, you can use `M-x next-file'.
`C-u M-x next-file'
With a numeric argument, regardless of its value, visit the first
file in the tags table and prepare to advance sequentially by
Visit the next file in the selected tags table.
automatically generated by info2www version 18.104.22.168