This add-in adds tags support to Visual Studio. It is similar to my Visual Studio macro Adding tags support to Visual Studio, but it is implemented as an add-in, which makes it more robust, and offers the user a choice if the tag is found more than once in the tags file. It also allows the specification of a default tags file, and includes case-matching and partial-matching options.
One reason I prefer using tags as opposed to the built-in Browse facilities is that I use other editors (Lemmy, and our own in-house editor) which use tags. Another advantage is that I can build my tags files at any time, without my code needing to be compilable.
To use the add-in, simply put it in the Common\MSDev98\AddIns directory under where-ever your Visual Studio is installed. Going to Tools | Customize, and picking the Add-ins and Macro Files tab will then list Tags Developer Studio Add-In as an available add-in. Turning on the add-in will add a new toolbar.
The toolbar will contain the following buttons:
- Push Tag
- Pop Tag
- Push Tag Prompt
- Clear Tag Stack
- Tag Options
- Edit Tag Stack
Clicking the Push Tag button will retrieve the selected text, or pick the current word if no text is selected, and look in the appropriate tags file to see if the tag exists. The tags file is first sought in the current file's directory, and if none is present the default tags file is used if specified, else the user is told that a tags file was not found. Once the tag is found, the add-in will jump to its location, or if there is more than one entry, will offer the user a list of possible locations to jump to, using the dialog shown below.
The list of tag entries may be sorted by any of the columns to make it easier to find the required tag location. Double-clicking an item, or selecting an item and clicking OK, will jump you to the tag.
The Push Tag Prompt button can be used to open the tag dialog and search for a tag by typing its name. You may override the case-sensitivity and partial match options for this search if you wish.
The Pop Tag button will jump you back to where you were, when the last tag was jumped to. If you have not jumped to a tag, or if you have 'popped' right back to your first location, then a message will tell you that the tag stack is empty. You may prevent these messages by switching off the Show messages option in the options dialog.
You may clear the tag stack at any time by clicking the Clear Tag Stack button. A message will tell you that the stack has been cleared, or that the stack is empty, unless you have switched off the Show messages option in the options dialog.
The add-in options are available by clicking the Tags Options button, and are shown in the following dialog:
Clicking the Edit Tag Stack button produces a dialog as shown below, which allows the tag stack to be edited.
You may jump to a location by double-clicking an item, or by selecting an item and clicking OK. Stack entries may be deleted by selecting one or more entries and clicking the Delete Entry button, or by hitting the Del key. The entire stack may also be cleared by clicking Clear Stack, whereupon the dialog will be closed.
Tag file generation
To generate my tags I use Exuberant Ctags, by Darren Hiebert. This is available as a free download from http://ctags.sourceforge.net/. The download location includes information on the options for generating tags.
Reading the tags file
The code used for reading the tags file is written by Darren Hiebert, and is included in the tags download mentioned above. The functions are defined in a file called readtags.c. They read the tags file each time a tag is searched for. These are very fast functions, and are, in my opinion, far better than reading the file into a map, list, or array, and keeping a list of tags files.
Whilst none of the code was taken from other sources (with the exception of the tag reading code mentioned above), the idea for the tag selection dialog was taken from Joshua Jensen's Workspace Utilities v1.75.
- Version 2.0 - 23 May 2003
- Added sorting to tag list in prompt dialog
- Added option to not show messages when clearing the tag stack etc.
- Added dialog for editing the tag stack
- Version 1.0 - 12 Jul 2002