Etags

When your C++ project is in several files, it can be hard to find the definition of a specific function without alot of hunting. Using tags simplifies this process.

Making tags

The program we use to make tags is called "etags".

Say we have the following files: splash_screen.cc, splash_screen.h, encrypt.cc, encrypt.h, main.cc. To make tags for these files, at the shell prompt type:

  etags splash_screen.h encrypt.h splash_screen.cc encrypt.cc main.cc
  

If you want to make tags for all the .h and .cc files in your current directory, you can type:

  etags *.h *.cc
  

You will get a file called "TAGS". If you want the file to have some other name, use the -f option, e.g.

  etags -f thistags splash_screen.h encrypt.h splash_screen.cc encrypt.cc main.cc
  

Using tags

We use emacs to use tags. Below are some commands. ("M" is the Meta key, and "C" is the Control key. "M" or "C" followed by "-" and some character means hold down the Meta or Control key and hit the character key at the same time.)

Used this way, tags only finds definitions, not declarations or calls. These commands also find declarations and calls, and allow you to replace all instances of a name:

A regular expression is simply a pattern which many things may match. We already use regular expressions. The regular expression "one" matches only instances of the word "one". The regular expression "*.cc" matches any word ending with ".cc". The regular expression "*" matches anything at all.

For More Information

There is quite a bit of information about etags both in the Unix man pages (a kind of on-line documentation) and in the Emacs info. To find out more about etags from the man pages, at the shell prompt type:

  man etags
  
or
  man ctags
  

To find out more about etags from the Emacs info you have to know how to use the Emacs info! To get to the info, from within an Emacs buffer type:

From there, other commands will let you move around.

The menus are clearly marked in the info.


Last modified 17 March 1997 by Amanda Stent