Loading ...
Sorry, an error occurred while loading the content.

83374Re: Tags best-practices for multiple projects?

Expand Messages
  • Tony Mechelynck
    Sep 30, 2007
      Mikael Jansson wrote:
      > Hey Tony!
      > >
      >> 2) all tagfiles collected together: it might be easier to handle if each
      >> tagfile is in the top directory for the corresponding project. This assumes
      >> that each project has its own directory structure, separate from every other
      >> project's. If you wish, you may add softlinks (if supported by your OS and
      >> filesystem) from ~/.tags/project1 to (e.g.) ~/.build/project1/tags (Reminder:
      >> every tagfile SHOULD be named "tags" if in Vim format, or "TAGS" if in Emacs
      >> format.)
      > >
      >> 3) auto-generated: see the "tags" target in src/Makefile in the Vim source for
      >> an example.
      > >
      > Not quite sure I understand what you mean by "automatic", here -- I
      > looked in the Makefile but couldn't find much useful that relates to
      > multiple-project tags. Then, I'm not very familiar with tags. I'd
      > appreciate some hand-holding in this matter.

      "make tags" generates tags for the Vim project (which, on my machine, has its
      files at ~/.build/vim/vim71/ and below). You could have a similar target in
      the makefiles for your other projects. If you want the tagfile regenerated in
      some project whenever you invoke "make" without arguments, then you could have
      a dependency for "tags" (or for some equivalent phony target) in the default
      target (such as "all") defined in the makefile for that project. Or else run
      "make tags" manually after running "make" or instead of it.

      >> 4) with (2) above, ":cd <projectdir>" ought to be enough to have Vim find the
      >> correct tagfile.
      > I'd need for vim to scan for the tags file in parent directories
      > successively until it reaches the root of my project directory and the
      > tags file. Would that be doable?

      yes, it's a matter of having the correct value in the 'tags' option. See
      ":help file-searching" and scroll down to "2) Upward search".

      set tags=tags,./tags;

      meaning: search for "tags" in the current directory, and upward starting at
      the directory of the current file. To limit the upward search, add a
      "stop-directory" after the semicolon.

      > Moreover, I'd probably need the tags from >1 project (but still separate
      > tags files!) -- can I make vim merge the inputted definitions and/or
      > read >1 tags file? Or do I have to do it manually by defining all
      > directories when creating the tags file, i.e. w/ ctags?
      > - Mikael

      Hm, why would you need the tagfiles from several projects at the same time?
      Wouldn't you want to limit the search to the project you're currently working on?

      From ":help tags-option" I seem to understand that all tagfiles in all dirs
      specified (including upward dirs if specified) are searched until a matching
      tag is found. What "matching" means in this context depends on the
      'ignorecase' setting. You could e.g. use

      set tags+=/usr/include/tags

      if you have generated a tagfile there for your common include files.

      To edit files from different projects in split-windows in a single Vim, then
      (if the default option of searching from the current file's dir doesn't suit
      you), remember that this option is |global-local| : you can use ":setlocal" to
      set a different value for one buffer.

      Best regards,
      Age, n.:
      That period of life in which we compound for the vices that we
      still cherish by reviling those that we no longer have the enterprise
      to commit.
      -- Ambrose Bierce

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 7 messages in this topic