Search code examples
vimctagsexuberant-ctags

How to specify where to generate the tags file


I currently have a project directory like this

MainProject
|_ProjectA
|   |_src
|      |_file1.cpp
|      |_file2.cpp
|      |_.....
|      |_tags <---tag file generated here  
|_ProjectB
|   |_src
|      |_file3.cpp
|      |_file4.cpp
|      |_.....
       |_tags <---tag file generated here

Now file4.cpp uses items in file1.cpp however it seems that since its in a different folder I get the message

cstag - tag not found

Currently i went into my ProjectA and ProjectB and did this for each

ctage -R .

as a result of which tags file got generated in each project. My question is how can I specify where to generate the tags file. In that case all the tags file will be next to each other and hopefully that will solve this problem


Solution

  • The simplest solution would be to generate a single tags file:

    $ cd MainProject
    $ ctags -R .
    

    and tell Vim to recurse upward when looking for tags files:

    set tags=./tags;,tags;