Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the easiest/best methods for managing your ctags tag file(s)?

I just started using ctags and greatly appreciate the tool but the way I manage my tag file is somewhat cumbersome in my opinion and very inflexible.

How I currently manage my tag file:

  1. I have one monolithic tag file stored in my home folder at ~/.vim/tags
  2. When I update my code or change projects I run a script that deletes the old tag file and regenerates the monolithic tag file (you have to change the location of where ctags executes from when you change projects)

Having one monolithic tag file works for me because it lets me jump to all the relevant symbols for the current project I am working on.

Would a single monolithic tag file will not work for a large/huge codebase? Why would a huge tag file not work on a large/huge codebase?

What are other ways to manage your tag file (or tag files plural)?

And why would your new method for managing your tag files be better? (Presumably a better solution would sometimes be more complex. So if your solution is more complex I am asking you what is the added benefit for a more complex method for managing your tag files.)


p.s. I found a stackoverflow question talking about ctags called "vimctags-tips-and-tricks" but this question doesn't talk about how to manage your tag files.

like image 866
Trevor Boyd Smith Avatar asked Aug 10 '09 19:08

Trevor Boyd Smith


People also ask

What are ctags files?

ctags creates a file named tags in the current directory. It summarizes the locations of various objects in the C source files named on the command line. All files with a . c or . h suffix are treated as C source files.

Where are ctags stored?

Ctags is a tool that will sift through your code, indexing methods, classes, variables, and other identifiers, storing the index in a tags file.


1 Answers

One approach I've recently become fond of is using VCS (Version Control Systems) hooks to generate the ctags files. I use git locally even for small projects and such, and so the ctags gets updated every time I commit (this is, obviously, possible with all other VCS's out there).

I personally like to place the ctags file in each project's directory, but this approach should work just as well globally.

EDIT: VCS hooks are scripts or programs that run automatically when certain actions are performed, such as checkout, commit, revert and others.
For further reading I suggest the following links:

  • Subversion: The Implementing Repository Hooks and Repository Hooks sections of the SVN book.
  • Git: The Git Hooks section of the Git Community Book.
  • Mercurial: The Handling repository events with hooks section from the online book Mercurial: The Definitive Guide.

Hooks are generally available in all VCS's I've bumped into, and I'm sure you'll be able to find documentation for the one you chose to use.

like image 65
drrlvn Avatar answered Sep 29 '22 20:09

drrlvn