Department of Engineering

IT Services


To assist movement within a multi-file source, you can set up tag files which stores the location of functions definitions, chapter headings etc that you might want to jump to by name. The syntax of C, Fortran and LaTeX files are understood.

From the command line go to the directory where you'll be working from and type

   etags <files>

(or etags -t <files> to record typedefs in C code too). This will create a file called TAGS. It doesn't matter if this file gets a bit out of date unless you move functions from one file to another. Just run etags again every so often. To load this tag file in, use

   M-x visit-tags-table

which will prompt for a file name (the default is TAGS). Now you can use

   M-. <tag>

to jump to the file and position of the definition of <tag>.

Since the TAGS file contains a list of files that you're interested in, you can use it to perform multi-file versions of emacs commands. Eg

  M-x tags-search   (then M-, to resume the search)
  M-x tags-query-replace

If you know you're going to visit a succession of files, use

  C-u M-x next-file

to look at the first file mentioned in TAGS and

  M-x next-file

to move to the next.

  M-x list-tags

asks for a file and tells you the tags defined in it.

  M-x tags-apropos

asks for a regexp and displays the matching tags.