sponsor Vim development Vim logo Vim Book Ad

Intelligent Tags : Automated Tag creation/inclusion

 script karma  Rating 11/5, Downloaded by 816  Comments, bugs, improvements  Vim wiki

created by
Stephen Bell
 
script type
utility
 
description
Project Home: https://github.com/bahejl/Intelligent_Tags

Intelligent Tags is designed to handle creating tags and setting the 'tag'
option for you.  Tradionally, you would run ctags on your project at regular
intervals (or in a cron job), but I struggled with this approach for several
reasons:
* I'm initially not familiar with the project structure of many of the
projects I work on, so I have to chase down the includes until I feel
comfortable that I know where the project ends/begins before I can create a
useful tags files.  This is a large overhead, and prevents me from using tags
when I need them the most.
* As I actively work on a project, updating the tags once a day, or even
every hour, just doesn't cut it.  I would like the tags to be updated as
soon as the file is updated.


Intelligent Tags solves these problems by using two tools.  First, it uses
Vim's built-in options 'include', and 'includeexpr' to find any/all
include files, and then searches those includes for includes, etc. The depth of this search
can be set by the user to any level using the |Itags_Depth| variable.  To save
time, Intelligent Tags will create an .incl file for every file examined.
This file is simply a cache that lets Intelligent Tags avoid re-scanning for
include files unless it is necessary.  In order for  any of this to work
properly, Vim's path option must be set correctly.  You can check if it is
correct by running the Vim command |:checkpath|.  If you use Intelligent Tags
with an incorrect path, the information stored in the cached .incl files
will be incorrect, and you will need to run the |ItagsRegenIncl| command after
correcting your path to correct the cached informaiton.  For more
information on setting your path type ':h path'.

The second tool Intelligent Tags uses is exhuberant ctags.  Intelligent Tags
uses exhuberant ctags' report of supported languages to automatically add a
FileType autocommand for each type of supported file.  I want my tags
updated as soon as I make a change to a file, but if you use the tradional
method of having a single tags file per project that can take quite a while
-- especially for a large project.  To work around that problem, Intelligent
Tags creates a seperate tags file for each source file, and only updates
those that are out of date.

This methodolgy begins to break down for some languages, such as C, where
the following problems exist:
* foo.c includes bar.h, followed by baz.h, so (almost magically) everything
in bar.h is available to baz.h.  Because Intelligent Tags works on a
per-file and not per-project basis, it is impossible (as far as I can tell)
for Intelligent Tags to know that bar.h's tags should be included based only
on the information in baz.h.
* foo.c includes bar.h, which contains externals defined in bar.c.
Intelligent Tags works around this problem by allowing for a special
|Itags_header_mapping| option.  If this is defined, when Intelligent Tags finds any
included file whose extension is recognized as a header, it will search for
a source file of the same name and include its tags as well.

In the end, when you open any exhuberant ctags supported file, intelligent
Tags will generate any tags files necessary and update the 'tags'
option for you -- you don't have to do a thing!
 
install details
You must have exhuberant ctags (http://ctags.sourceforge.net/) installed.
Uncompress intelliTags.vim.gz, open it in vim, and then type ":so%"
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
intelliTags.vba.gz 0.2 2011-07-26 7.0 Stephen Bell * Added Documenation
* Now distributing as a vimball
intelliTags.vim 0.1 2011-07-21 7.0 Stephen Bell Initial upload
ip used for rating: 3.15.193.45

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github