Search code examples
phpvimctagsexuberant-ctags

Tell Ctags not to parse content inside comments


When I generate my ctags file, it seems to be parsing content inside comments too. For instance, using Vim's plugin Tagbar, I can see in the list of functions non-existent functions such as:

  • is
  • in
  • just

What is happening here is that ctags is going into comments and finding things like:

"This function is...", thinking that "is" is a function, it is then adding an entry for it in the tags file.

I am wondering if there is an easy way to tell ctags not to parse contents inside comments.

I have found that apparently there was a fix for this to be released after 5.8.0 but I am not sure whether this has already been released or not, my ctags version is 5.8.0.

This is related to a PHP project but I guess it would be nice if the answer can cover a solution that would work for any programming language (if such a thing is possible).

Example:

The following comment to a function generates the tag "is" and lists it as a function:

/**
 * This function is run to set certain preferences
 */

Solution

  • There's a bug in ctags 5.8. Fortunately, one day after it was released, jafl committed revision 729 to fix the problem. Unfortunately, there has not been a release since then.

    Fortunately, the project has been forked as "Universal Ctags." Here's how to install that from source.

    # Get rid of 5.8.
    sudo apt-get remove exuberant-ctags
    
    # autoconf is needed to assemble the configure files
    sudo apt-get install autoconf autoconf-doc
    
    git clone https://github.com/universal-ctags/ctags.git universal-ctags
    
    cd universal-ctags
    
    ./autogen.sh
    ./configure
    make
    
    sudo make install