7

When I build/update my tags file, ctags starts at the current directory and works its way down recursively.

I would like for it to also include a completely different search path, a mapped network drive, and add those results to my tags file as well.

Is there any way to do that?

4
  • Did you read $ man ctags before asking? If so, did you try something? If so, what worked? What failed? If not, do you at least have a theory? Commented Oct 23, 2013 at 22:18
  • I did. I understand that I can provide a file with paths to directories, but that means that I would have to hardcode all of my paths in (right?), which I dont want to do. I want one hardcoded path, and the rest to be based off my current directory. Commented Oct 23, 2013 at 22:22
  • 1
    Actually, I think I could just generate tags in the "other" directory manually, they're mostly windows headers and junk so they'll rarely need to be updated, then I could do a set ctags+= /path/to/other/dir, to include another tag file. hooray. Commented Oct 23, 2013 at 22:38
  • If on linux, you want to create a sym link in your source code dir like ln -s \path\to\linux . and run ctags like ctags --recurse=yes --exclude=.git --exclude=BUILD --exclude=.svn --exclude=vendor/* --exclude=node_modules/* --exclude=db/* --exclude=log/* Commented Nov 29, 2024 at 19:20

1 Answer 1

12

In vim, one can do like below to include the tags file from other directories as well.

:set tags+=/path/to/other/dir/tags 

NOTE: Add the tag filename at the end, else there will be "tag not found" error. By default the name is tags but it could be renamed with -f option as below to my_tags when generating it in cli.

$ ctags -f my_tags -R 

Now, in vim do

:set tags+=/path/to/other/dir/my_tags 

where my_tags is the name of the tag file.

This way any number of tags file can be updated within vim to access them through Ctrl + ] or :tag fnName or similar.

Sign up to request clarification or add additional context in comments.

1 Comment

This is great advice. As a follow up, can you do something similar for cscope?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.