Virtual Developer Workshop: Containerized Development with Docker


Environment: VC6 (probably any VC)

What's all this then?

Having programmed on a UNIX platform, where I used the vi editor, and since then on a PC using Lemmy, I have missed the ability to use tags when using Visual Studio. The macro published here provides tags support.

To use the macro file, simply put it in the Common\MSDev98\Macros directory under where-ever your Visual Studio is installed. The macro file exposes two functions (listed below). These functions can be mapped to keys of your choice.

The functions are as follows:

PushContext: Invoking this function picks up the currently selected text, and looks for a reference to it in the tags file. If it finds it in the file, it then opens the file it is contained in and jumps to the correct line or text. The current cursor position (and file) is added to the tag stack.

PopContext: This function will take the top entry from the tag stack, and jump to the file and cursor position listed there. This enables you to jump to a definition, and then come back to where you were previously working. This works regardless of whether the tag jumped to was in the same file or a different file.

So why not use the browser facilities built-in to Visual Studio?

One of the things I like about tags that the browser info doesn't give me is the ability to stack the tags, so I jump back to where I came from.

Mmm, looks useful, but how do I generate my tags?

To generate my tags I use Exuberant Ctags, by Darren Hiebert. This is available as a free download from http://ctags.sourceforge.net/. One thing to be careful of is that if you create the tags file by specifying a directory, then the file paths are stored as relative paths in the tags file. This then causes problems, as Visual Studio may change its current directory each time you open a file.

How it works

When you first execute the PushContext function, the tags file is sought in the directory in which the current file lives. If it is found, then its contents are read in line by line, and the tag text is added to a dictionary, along with the tag information (file path, and line number or search text). (This does mean that the first time you read a tags file, there is a bit of a delay, but after that it is quite fast.)

A separate dictionary is kept for each tags file you read, and a dictionary of dictionaries is used to get back the correct dictionary. This means that different directories can use different tags files.

Before reading in a tags file, the master dictionary is searched to see if there is already a dictionary for that file. If there is, then the time stamp of the file is compared to a saved timestamp in the dictionary, to see if the tags file needs re-reading. This enables you to update your tags at any time, and still be able to use them correctly.


If the tag text is listed in the file more than once, then the only the first occurance will be used. To avoid this causing problems, use care when creating your tags file, to ensure that the more important files are scanned first, and generate a non-sorted tags file.


Download source - 3 Kb


  • Find the tag file in the project home dir...

    Posted by Legacy on 07/05/2002 07:00am

    Originally posted by: Matthieu

    If you prefer to have several projects and not only one tag file is to refer it from the project base directory.
    You'll need to use --tag-relative option from ctags and change the following lines from the original macro

    < str = ActiveProject.FullName
    < pos = inStrRev(str, "\")
    < default_tags_path = left(str, pos)
    > const default_tags_path = "c:"
    < file = default_tags_path + file

    Have fun !


  • Browse info - pros and cons

    Posted by Legacy on 03/14/2001 08:00am

    Originally posted by: Peter Andersson


    I noticed the following comment:

    "So why not use the browser facilities built-in to Visual Studio? One of the things I like about tags that the browser info doesn't give me is the ability to stack the tags, so I jump back to where I came from. "

    There is a command in MSDEV called BrowsePopContext (bound to Ctrl-* when using the classic Visual C 2.0 keys) so you CAN push and pop the context.

    I always hit F11 to check the definition, then use Ctrl-* to get back to where I were.

    I haven't used the "tags" package yet since the built-in browser info actually is very good. However, MS seems to want to want people to stay away from this functionality, by not promoting/developing it. For example, browsing info is no longer turned on by default, and the GUI hasn't changed in years.

    The downside with using the browser is:
    - BSCMAKE can take a long time to finish
    - There are NO reporting facilities, printing etc of this potentially very useful information

    You can of course use the BROWSE API, and make your own app, but so far I haven't gotten around to doing that. I'm a little bit surprised that noone else have done it either.


  • Nice job

    Posted by Legacy on 03/13/2001 08:00am

    Originally posted by: Trance

    Also, for those interested, there is another tool which is not a plug in. It's called Developer's Notepad, and is available for free from http://www.relisoft.com. It operates on the same principles.

  • www.vadaumuie.ro

    Posted by Legacy on 03/12/2001 08:00am

    Originally posted by: gigi

    Imi bag pula!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date