Assuming I have a code directory structure as follows:
/top
/second
/core
a.pl
b.pl
c.pl
/common
d.pl
e.pl
/util
f.pl
g.pl
h.pl
Where should I run the ctags
so that I can jump to function definitions via vi
?
For example I had:
/dir
/perl
a.pl
and I run in dir
the command ctags -R perl
but in a.pl
I could not jump to a function definition that existed in the same file.
If I did ctags -R .
inside the perl
directory it worked.
So I can not understand the pattern. Should I run ctags
in core, common,util
? What if my code base is huge? Would I really need to run it in each directory?
Your tags
file should be generated in the first common ancestor of your code (that would be second
, in your case) with $ ctags -R .
.
I'd suggest you add this line to your ~/.vimrc
in order to make Vim always find your tags
file, no matter where you are in your project and no matter what the "current directory" is:
set tags=./tags;/,tags;/
It works like the one in @glts's answer with an interesting twist: because of the ;/
part, Vim looks up and up until /
for a tags
file. Supposing you are editing g.pl
, Vim will correctly use your tags
file located in second
.
:h tags
:h ctags