1*94eb5533SMasatake YAMATOvberthoux@users.sourceforge.netFrequently Asked Questions 2*94eb5533SMasatake YAMATO========================== 3*94eb5533SMasatake YAMATO 4*94eb5533SMasatake YAMATO * 1. Why do you call it "Exuberant Ctags"? 5*94eb5533SMasatake YAMATO * 2. Why doesn't my editor work with these tag files? 6*94eb5533SMasatake YAMATO * 3. What are these strange bits of text beginning with ;"? 7*94eb5533SMasatake YAMATO * 4. Why doesn't XEmacs' Speedbar module work with Exuberant Ctags? 8*94eb5533SMasatake YAMATO * 5. Why doesn't Xemacs correctly locate the tag in the source file? 9*94eb5533SMasatake YAMATO * 6. Why doesn't NEdit correctly locate the tag in the source file? 10*94eb5533SMasatake YAMATO * 7. Why can't I jump to "class::member"? 11*94eb5533SMasatake YAMATO * 8. How can I avoid having to specify my favorite option every time? 12*94eb5533SMasatake YAMATO * 9. Why do I end up on the wrong line when I jump to a tag? 13*94eb5533SMasatake YAMATO * 10. How do I jump to the tag I want instead of the wrong one by the 14*94eb5533SMasatake YAMATO same name? 15*94eb5533SMasatake YAMATO * 11. What is "Vim"? 16*94eb5533SMasatake YAMATO * 12. How can I locate all references to a specific function or variable? 17*94eb5533SMasatake YAMATO * 13. Why does appending tags to a tag file tag so long? 18*94eb5533SMasatake YAMATO * 14. How do I get regex support for Win32? 19*94eb5533SMasatake YAMATO * 15. How should I set up tag files for a multi-level directory hierarchy? 20*94eb5533SMasatake YAMATO 21*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 22*94eb5533SMasatake YAMATO1. Why do you call it "Exuberant Ctags"? 23*94eb5533SMasatake YAMATO 24*94eb5533SMasatake YAMATOBecause one of the meanings of the word "exuberant" is: 25*94eb5533SMasatake YAMATO 26*94eb5533SMasatake YAMATO exuberant : produced in extreme abundance : PLENTIFUL syn see PROFUSE 27*94eb5533SMasatake YAMATO 28*94eb5533SMasatake YAMATOCompare the tag file produced by Exuberant Ctags with that produced by any 29*94eb5533SMasatake YAMATOother ctags and you will see how appropriate the name is. 30*94eb5533SMasatake YAMATO 31*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 32*94eb5533SMasatake YAMATO2. Why doesn't my editor work with these tag files? 33*94eb5533SMasatake YAMATO 34*94eb5533SMasatake YAMATO3. What are these strange bits of text beginning with ;" which follow 35*94eb5533SMasatake YAMATO many of the lines in the tag file? 36*94eb5533SMasatake YAMATO 37*94eb5533SMasatake YAMATOThese are "extension flags". They are added in order to provide extra 38*94eb5533SMasatake YAMATOinformation about the tag that may be utilized by the editor in order to 39*94eb5533SMasatake YAMATOmore intelligently handle tags. They are appended to the EX command part of 40*94eb5533SMasatake YAMATOthe tag line in a manner that provides backwards compatibility with existing 41*94eb5533SMasatake YAMATOimplementations of the Vi editor. The semicolon is an EX command separator 42*94eb5533SMasatake YAMATOand the double quote begins an EX comment. Thus, the extension flags appear 43*94eb5533SMasatake YAMATOas an EX comment and should be ignored by the editor when it processes the 44*94eb5533SMasatake YAMATOEX command. 45*94eb5533SMasatake YAMATO 46*94eb5533SMasatake YAMATOSome non-vi editors, however, implement only the bare minimum of EX commands 47*94eb5533SMasatake YAMATOin order to process the search command or line number in the third field of 48*94eb5533SMasatake YAMATOthe tag file. If you encounter this problem, use the option "--format=1" to 49*94eb5533SMasatake YAMATOgenerate a tag file without these extensions (remember that you can set the 50*94eb5533SMasatake YAMATOCTAGS environment variable to any default arguments you wish to supply). Then 51*94eb5533SMasatake YAMATOask the supplier of your editor to implement handling of this feature of EX 52*94eb5533SMasatake YAMATOcommands. 53*94eb5533SMasatake YAMATO 54*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 55*94eb5533SMasatake YAMATO4. Why doesn't XEmacs' Speedbar module work with Exuberant Ctags? 56*94eb5533SMasatake YAMATO 57*94eb5533SMasatake YAMATOThe default command line switches used by XEmacs for "etags" are not 58*94eb5533SMasatake YAMATOcompatible with Exuberant Ctags options. By default, Exuberant Ctags installs 59*94eb5533SMasatake YAMATOa symbolic link, "etags", pointing to the ctags executable. When Exuberant 60*94eb5533SMasatake YAMATOCtags is started with the name "etags", it produces Emacs-style tag files by 61*94eb5533SMasatake YAMATOdefault. 62*94eb5533SMasatake YAMATO 63*94eb5533SMasatake YAMATOTo fix this, add the following lines to your .emacs file, replacing the path 64*94eb5533SMasatake YAMATOto "etags" with the path where the symbolic link was installed. 65*94eb5533SMasatake YAMATO 66*94eb5533SMasatake YAMATO(autoload 'speedbar "speedbar") 67*94eb5533SMasatake YAMATO(setq speedbar-fetch-etags-command "/usr/local/bin/etags" 68*94eb5533SMasatake YAMATO speedbar-fetch-etags-arguments '("-f" "-")) 69*94eb5533SMasatake YAMATO 70*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 71*94eb5533SMasatake YAMATO5. Why doesn't Xemacs correctly locate the tag in the source file? 72*94eb5533SMasatake YAMATO 73*94eb5533SMasatake YAMATOThis has been observed with version 20.3. It seems that when Xemacs searches 74*94eb5533SMasatake YAMATOfor a tag, it searches using the tag name instead of the search string located 75*94eb5533SMasatake YAMATOin the TAGS file. This is a bug in Xemacs and does not occur in the GNU 76*94eb5533SMasatake YAMATOversion of Emacs. 77*94eb5533SMasatake YAMATO 78*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 79*94eb5533SMasatake YAMATO6. Why doesn't NEdit correctly locate the tag in the source file? 80*94eb5533SMasatake YAMATO 81*94eb5533SMasatake YAMATOVersions of NEdit prior to 5.1 did not support the extended tag file format 82*94eb5533SMasatake YAMATOgenerated by Exuberant Ctags by default. Either upgrade to version 5.1 or 83*94eb5533SMasatake YAMATOspecify the option "--format=1" when running ctags to output the old tag file 84*94eb5533SMasatake YAMATOformat. 85*94eb5533SMasatake YAMATO 86*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 87*94eb5533SMasatake YAMATO7. Why can't I jump to "class::member"? 88*94eb5533SMasatake YAMATO 89*94eb5533SMasatake YAMATOBecause, by default, ctags only generates tags for the separate identifiers 90*94eb5533SMasatake YAMATOfound in the source files. If you specify the --extra=+q option, then 91*94eb5533SMasatake YAMATOctags will also generate a second, class-qualified tag for each class member 92*94eb5533SMasatake YAMATO(data and function/method) in the form class::member for C++, and in the form 93*94eb5533SMasatake YAMATOclass.method for Eiffel and Java. 94*94eb5533SMasatake YAMATO 95*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 96*94eb5533SMasatake YAMATO8. How can I avoid having to specify my favorite option every time? 97*94eb5533SMasatake YAMATO 98*94eb5533SMasatake YAMATOEither by setting the environment variable CTAGS to your custom 99*94eb5533SMasatake YAMATOoptions, or putting them into a .ctags file in your home directory. 100*94eb5533SMasatake YAMATO 101*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 102*94eb5533SMasatake YAMATO9. Why do I end up on the wrong line when I jump to a tag? 103*94eb5533SMasatake YAMATO 104*94eb5533SMasatake YAMATOBy default, ctags encodes the line number in the file where macro (#define) 105*94eb5533SMasatake YAMATOtags are found. This was done to remain compatible with the original UNIX 106*94eb5533SMasatake YAMATOversion of ctags. If you change the file containing the tag without 107*94eb5533SMasatake YAMATOrebuilding the tag file, the location of tag in the tag file may no longer 108*94eb5533SMasatake YAMATOmatch the current location. 109*94eb5533SMasatake YAMATO 110*94eb5533SMasatake YAMATOIn order to avoid this problem, you can specify the option "--excmd=p", 111*94eb5533SMasatake YAMATOwhich causes ctags to use a search pattern to locate macro tags. I have 112*94eb5533SMasatake YAMATOnever uncovered the reason why the original UNIX ctags used line numbers 113*94eb5533SMasatake YAMATOexclusively for macro tags, but have so far resisted changing the default 114*94eb5533SMasatake YAMATObehaviour of Exuberant Ctags to behave differently. 115*94eb5533SMasatake YAMATO 116*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 117*94eb5533SMasatake YAMATO10. How do I jump to the tag I want instead of the wrong one by the 118*94eb5533SMasatake YAMATO same name? 119*94eb5533SMasatake YAMATO 120*94eb5533SMasatake YAMATOA tag file is simple a list of tag names and where to find them. If there 121*94eb5533SMasatake YAMATOare duplicate entries, you often end up going to the wrong one because the 122*94eb5533SMasatake YAMATOtag file is sorted and your editor locates the first one in the tag file. 123*94eb5533SMasatake YAMATO 124*94eb5533SMasatake YAMATOStandard Vi provides no facilities to alter this behavior. However, Vim 125*94eb5533SMasatake YAMATOhas some nice features to minimize this problem, primarly by examining all 126*94eb5533SMasatake YAMATOmatches and choosing the best one under the circumstances. Vim also provides 127*94eb5533SMasatake YAMATOcommands which allow for selection of the desired matching tag. 128*94eb5533SMasatake YAMATO 129*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 130*94eb5533SMasatake YAMATO11. What is "Vim"? 131*94eb5533SMasatake YAMATO 132*94eb5533SMasatake YAMATOVim is a vi-compatible editor available as source and compilable for any 133*94eb5533SMasatake YAMATOplatform. Yeah, I know the first reaction is to shy away from this. But you 134*94eb5533SMasatake YAMATOwill never regret getting it, and you will become greatly attached to its 135*94eb5533SMasatake YAMATOfeatures, which you can learn gradually. I would be willing to say that it 136*94eb5533SMasatake YAMATOis the best vi-clone available within 4 light-years of Alpha Centauri. It 137*94eb5533SMasatake YAMATOworks (nearly) exactly like standard vi, but provides some incredibly useful 138*94eb5533SMasatake YAMATOextensions (some of which I have participated in designing with the author). 139*94eb5533SMasatake YAMATOMost Linux distributions have adopted Vim as its standard vi. 140*94eb5533SMasatake YAMATO 141*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 142*94eb5533SMasatake YAMATO12. How can I locate all references to a specific function or variable? 143*94eb5533SMasatake YAMATO 144*94eb5533SMasatake YAMATOThere are several packages already available which provide this capability. 145*94eb5533SMasatake YAMATONamely, these are: GLOBAL source code tag system, GNU id-utils, cscope, 146*94eb5533SMasatake YAMATOand cflow. As of this writing, they can be found in the following locations: 147*94eb5533SMasatake YAMATO 148*94eb5533SMasatake YAMATOGLOBAL: http://www.gnu.org/software/global 149*94eb5533SMasatake YAMATOid-utils: http://www.gnu.org/software/idutils/idutils.html 150*94eb5533SMasatake YAMATOcscope: http://cscope.sourceforge.net 151*94eb5533SMasatake YAMATOcflow: ftp://www.ibiblio.org/pub/Linux/devel/lang/c 152*94eb5533SMasatake YAMATO 153*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 154*94eb5533SMasatake YAMATO13. Why does appending tags to a tag file tag so long? 155*94eb5533SMasatake YAMATO 156*94eb5533SMasatake YAMATOSometimes, in an attempt to build a global tag file for all source files in 157*94eb5533SMasatake YAMATOa large source tree of many directories, someone will make an attempt to run 158*94eb5533SMasatake YAMATOctags in append (-a) mode on every directory in the hierarchy. Each time 159*94eb5533SMasatake YAMATOctags is invoked, its default behavior is to sort the tag file once the tags 160*94eb5533SMasatake YAMATOfor that execution have been added. As the cumulative tag file grows, the sort 161*94eb5533SMasatake YAMATOtime increases arithmetically. 162*94eb5533SMasatake YAMATO 163*94eb5533SMasatake YAMATOThe best way to avoid this problem (and the most efficient) is to make 164*94eb5533SMasatake YAMATOuse of the --recurse (or -R) option of ctags by executing the following 165*94eb5533SMasatake YAMATOcommand in the root of the directory hierarchy (thus running ctags only once): 166*94eb5533SMasatake YAMATO 167*94eb5533SMasatake YAMATO ctags -R 168*94eb5533SMasatake YAMATO 169*94eb5533SMasatake YAMATOIf you really insist on running ctags separately on each directory, you can 170*94eb5533SMasatake YAMATOavoid the sort pass each time by specifying the option "--sort=no". Once the 171*94eb5533SMasatake YAMATOtag file is completely built, use the sort command to manually sort the 172*94eb5533SMasatake YAMATOfinal tag file, or let the final invocation of ctags sort the file. 173*94eb5533SMasatake YAMATO 174*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 175*94eb5533SMasatake YAMATO14. How do I get regex support for Win32? 176*94eb5533SMasatake YAMATO 177*94eb5533SMasatake YAMATOYou need to download the GNU regex package for Win32 from the following 178*94eb5533SMasatake YAMATOlocation: 179*94eb5533SMasatake YAMATO 180*94eb5533SMasatake YAMATO http://people.delphiforums.com/gjc/gnu_regex.html 181*94eb5533SMasatake YAMATO 182*94eb5533SMasatake YAMATOThen point the makefile macro, REGEX_DIR, found in mk_mvc.mak and mk_bc5.mak, 183*94eb5533SMasatake YAMATOto the directory created by extracting this archive. 184*94eb5533SMasatake YAMATO 185*94eb5533SMasatake YAMATO ---------------------------------------------------------------------- 186*94eb5533SMasatake YAMATO15. How should I set up tag files for a multi-level directory hierarchy? 187*94eb5533SMasatake YAMATO 188*94eb5533SMasatake YAMATOThere are a few ways of approaching this: 189*94eb5533SMasatake YAMATO 190*94eb5533SMasatake YAMATO1. A local tag file in each directory containing only the tags for source 191*94eb5533SMasatake YAMATO files in that directory. 192*94eb5533SMasatake YAMATO 193*94eb5533SMasatake YAMATO2. One single big, global tag file present in the root directory of your 194*94eb5533SMasatake YAMATO hierarchy, containing all tags present in all source files in the 195*94eb5533SMasatake YAMATO hierarchy. 196*94eb5533SMasatake YAMATO 197*94eb5533SMasatake YAMATO3. A local tag file in each directory containing only the tags for source 198*94eb5533SMasatake YAMATO files in that directory, in addition to one single global tag file 199*94eb5533SMasatake YAMATO present in the root directory of your hierarchy, containing all 200*94eb5533SMasatake YAMATO non-static tags present in all source files in the hierarchy. 201*94eb5533SMasatake YAMATO 202*94eb5533SMasatake YAMATO4. A local tag file in each directory of the hierarchy, each one 203*94eb5533SMasatake YAMATO containing all tags present in source files in that directory and all 204*94eb5533SMasatake YAMATO non-static tags in every directory below it (note that this implies 205*94eb5533SMasatake YAMATO also having one big tag file in the root directory of the hierarchy). 206*94eb5533SMasatake YAMATO 207*94eb5533SMasatake YAMATOEach of these approaches has its own set of advantages and disadvantages, 208*94eb5533SMasatake YAMATOdepending upon your particular conditions. Which approach is deemed best 209*94eb5533SMasatake YAMATOdepends upon the following factors: 210*94eb5533SMasatake YAMATO 211*94eb5533SMasatake YAMATOA. The ability of your editor to use multiple tag files. 212*94eb5533SMasatake YAMATO 213*94eb5533SMasatake YAMATO If your editor cannot make use of multiple tag files (original vi 214*94eb5533SMasatake YAMATO implementations could not), then one large tag file is the only way to 215*94eb5533SMasatake YAMATO go if you ever desire to jump to tags located in other directories. If 216*94eb5533SMasatake YAMATO you never need to jump to tags in another directory (i.e. the source 217*94eb5533SMasatake YAMATO in each directory is entirely self-contained), then a local tag file 218*94eb5533SMasatake YAMATO in each directory will fit your needs. 219*94eb5533SMasatake YAMATO 220*94eb5533SMasatake YAMATOB. The time is takes for your editor to look up a tag in the tag file. 221*94eb5533SMasatake YAMATO 222*94eb5533SMasatake YAMATO The significance of this factor depends upon the size of your source 223*94eb5533SMasatake YAMATO tree and on whether the source files are located on a local or remote 224*94eb5533SMasatake YAMATO file system. For source and tag files located on a local file system, 225*94eb5533SMasatake YAMATO looking up a tag is not as big a hit as one might first imagine, since 226*94eb5533SMasatake YAMATO vi implementations typically perform a binary search on a sorted tag 227*94eb5533SMasatake YAMATO file. This may or may not be true for the editor you use. For files 228*94eb5533SMasatake YAMATO located on a remote file system, reading a large file is an expensive 229*94eb5533SMasatake YAMATO operation. 230*94eb5533SMasatake YAMATO 231*94eb5533SMasatake YAMATOC. Whether or not you expect the source code to change and the time it 232*94eb5533SMasatake YAMATO takes to rebuild a tag file to account for changes to the source code. 233*94eb5533SMasatake YAMATO 234*94eb5533SMasatake YAMATO While Exuberant Ctags is particularly fast in scanning source code 235*94eb5533SMasatake YAMATO (around 1-2 MB/sec), a large project may still result in objectionable 236*94eb5533SMasatake YAMATO delays if one wishes to keep their tag file(s) up to date on a 237*94eb5533SMasatake YAMATO frequent basis, or if the files are located on a remote file system. 238*94eb5533SMasatake YAMATO 239*94eb5533SMasatake YAMATOD. The presence of duplicate tags in the source code and the ability to 240*94eb5533SMasatake YAMATO handle them. 241*94eb5533SMasatake YAMATO 242*94eb5533SMasatake YAMATO The impact of this factor is influenced by the following three issues: 243*94eb5533SMasatake YAMATO 244*94eb5533SMasatake YAMATO 1. How common are duplicate tags in your project? 245*94eb5533SMasatake YAMATO 246*94eb5533SMasatake YAMATO 2. Does your editor provide any facilities for dealing with duplicate 247*94eb5533SMasatake YAMATO tags? 248*94eb5533SMasatake YAMATO 249*94eb5533SMasatake YAMATO While standard vi does not, many modern vi implementations, such 250*94eb5533SMasatake YAMATO as Vim have good facilities for selecting the desired match from 251*94eb5533SMasatake YAMATO the list of duplicates. If your editor does not support duplicate 252*94eb5533SMasatake YAMATO tags, then it will typically send you to only one of them, whether 253*94eb5533SMasatake YAMATO or not that is the one you wanted (and not even notifying you that 254*94eb5533SMasatake YAMATO there are other potential matches). 255*94eb5533SMasatake YAMATO 256*94eb5533SMasatake YAMATO 3. What is the significance of duplicate tags? 257*94eb5533SMasatake YAMATO 258*94eb5533SMasatake YAMATO For example, if you have two tags of the same name from entirely 259*94eb5533SMasatake YAMATO isolated software components, jumping first to the match found 260*94eb5533SMasatake YAMATO in component B while working in component A may be entirely 261*94eb5533SMasatake YAMATO misleading, distracting or inconvenient (to keep having to choose 262*94eb5533SMasatake YAMATO which one if your editor provides you with a list of matches). 263*94eb5533SMasatake YAMATO However, if you have two tags of the same name for parallel builds 264*94eb5533SMasatake YAMATO (say two initialization routines for different hosts), you may 265*94eb5533SMasatake YAMATO always want to specify which one you want. 266*94eb5533SMasatake YAMATO 267*94eb5533SMasatake YAMATOOf the approaches listed above, I tend to favor Approach 3. My editor of 268*94eb5533SMasatake YAMATOchoice is Vim, which provides a rich set of features for handling multiple 269*94eb5533SMasatake YAMATOtag files, which partly influences my choice. If you are working with 270*94eb5533SMasatake YAMATOsource files on a remote file system, then I would recommend either 271*94eb5533SMasatake YAMATOApproach 3 or Approach 4, depending upon the hit when reading the global 272*94eb5533SMasatake YAMATOtag file. 273*94eb5533SMasatake YAMATO 274*94eb5533SMasatake YAMATOThe advantages of Approach 3 are many (assuming that your editor has 275*94eb5533SMasatake YAMATOthe ability to support both multiple tag files and duplicate tags). All 276*94eb5533SMasatake YAMATOlookups of tag located in the currect directory are fast and the local 277*94eb5533SMasatake YAMATOtag file can be quickly and easily regenerated in one second or less 278*94eb5533SMasatake YAMATO(I have even mapped a keystroke to do this easily). A lookup of a 279*94eb5533SMasatake YAMATO(necessarily non-static) tag found in another directory fails a lookup in 280*94eb5533SMasatake YAMATOthe local tag file, but is found in the global tag file, which satisfies 281*94eb5533SMasatake YAMATOall cross-directory lookups. The global tag file can be automatically 282*94eb5533SMasatake YAMATOregenerated periodically with a cron job (and perhaps the local tag files 283*94eb5533SMasatake YAMATOalso). 284*94eb5533SMasatake YAMATO 285*94eb5533SMasatake YAMATONow I give an example of how you would implement Approach 3. Means of 286*94eb5533SMasatake YAMATOimplementing the other approaches can be performed in a similar manner. 287*94eb5533SMasatake YAMATO 288*94eb5533SMasatake YAMATOHere is a visual representation of an example directory hierarchy: 289*94eb5533SMasatake YAMATO 290*94eb5533SMasatake YAMATOproject 291*94eb5533SMasatake YAMATO `-----misccomp 292*94eb5533SMasatake YAMATO | `... 293*94eb5533SMasatake YAMATO `-----sysint 294*94eb5533SMasatake YAMATO `-----client 295*94eb5533SMasatake YAMATO | `-----hdrs 296*94eb5533SMasatake YAMATO | `-----lib 297*94eb5533SMasatake YAMATO | `-----src 298*94eb5533SMasatake YAMATO | `-----test 299*94eb5533SMasatake YAMATO `-----common 300*94eb5533SMasatake YAMATO | `-----hdrs 301*94eb5533SMasatake YAMATO | `-----lib 302*94eb5533SMasatake YAMATO | `-----src 303*94eb5533SMasatake YAMATO | `-----test 304*94eb5533SMasatake YAMATO `-----server 305*94eb5533SMasatake YAMATO `-----hdrs 306*94eb5533SMasatake YAMATO `-----lib 307*94eb5533SMasatake YAMATO `-----src 308*94eb5533SMasatake YAMATO `-----test 309*94eb5533SMasatake YAMATO 310*94eb5533SMasatake YAMATOHere is a recommended solution (conceptually) to build the tag files: 311*94eb5533SMasatake YAMATO 312*94eb5533SMasatake YAMATO1. Within each of the leaf nodes (i.e. hdrs, lib, src, test) build a tag 313*94eb5533SMasatake YAMATO file using "ctags *.[ch]". This can be easily be done for the whole 314*94eb5533SMasatake YAMATO hierarchy by making a shell script, call it "dirtags", containing the 315*94eb5533SMasatake YAMATO following lines: 316*94eb5533SMasatake YAMATO 317*94eb5533SMasatake YAMATO #!/bin/sh 318*94eb5533SMasatake YAMATO cd $1 319*94eb5533SMasatake YAMATO ctags * 320*94eb5533SMasatake YAMATO 321*94eb5533SMasatake YAMATO Now execute the following command: 322*94eb5533SMasatake YAMATO 323*94eb5533SMasatake YAMATO find * -type d -exec dirtags {} \; 324*94eb5533SMasatake YAMATO 325*94eb5533SMasatake YAMATO These tag files are trivial (and extremely quick) to rebuild while 326*94eb5533SMasatake YAMATO making changes within a directory. The following Vim key mapping is 327*94eb5533SMasatake YAMATO quite useful to rebuild the tag file in the directory of the current 328*94eb5533SMasatake YAMATO source file: 329*94eb5533SMasatake YAMATO 330*94eb5533SMasatake YAMATO :nmap ,t :!(cd %:p:h;ctags *.[ch])&<CR><CR> 331*94eb5533SMasatake YAMATO 332*94eb5533SMasatake YAMATO2. Build the global tag file: 333*94eb5533SMasatake YAMATO 334*94eb5533SMasatake YAMATO cd ~/project 335*94eb5533SMasatake YAMATO ctags --file-scope=no -R 336*94eb5533SMasatake YAMATO 337*94eb5533SMasatake YAMATO thus constructing a tag file containing only non-static tags for all 338*94eb5533SMasatake YAMATO source files in all descendent directories. 339*94eb5533SMasatake YAMATO 340*94eb5533SMasatake YAMATO3. Configure your editor to read the local tag file first, then consult 341*94eb5533SMasatake YAMATO the global tag file when not found in the local tag file. In Vim, 342*94eb5533SMasatake YAMATO this is done as follows: 343*94eb5533SMasatake YAMATO 344*94eb5533SMasatake YAMATO :set tags=./tags,tags,~/project/tags 345*94eb5533SMasatake YAMATO 346*94eb5533SMasatake YAMATOIf you wish to implement Approach 4, you would need to replace the 347*94eb5533SMasatake YAMATO"dirtags" script of step 1 with the following: 348*94eb5533SMasatake YAMATO 349*94eb5533SMasatake YAMATO #!/bin/sh 350*94eb5533SMasatake YAMATO cd $1 351*94eb5533SMasatake YAMATO ctags * 352*94eb5533SMasatake YAMATO # Now append the non-static tags from descendent directories 353*94eb5533SMasatake YAMATO find * -type d -prune -print | ctags -aR --file-scope=no -L- 354*94eb5533SMasatake YAMATO 355*94eb5533SMasatake YAMATOAnd replace the configuration of step 3 with this: 356*94eb5533SMasatake YAMATO 357*94eb5533SMasatake YAMATO :set tags=./tags;$HOME,tags 358*94eb5533SMasatake YAMATO 359*94eb5533SMasatake YAMATOAs a caveat, it should be noted that step 2 builds a global tag file whose 360*94eb5533SMasatake YAMATOfile names will be relative to the directory in which the global tag file 361*94eb5533SMasatake YAMATOis being built. This takes advantage of the Vim 'tagrelative' option, 362*94eb5533SMasatake YAMATOwhich causes the path to be interpreted a relative to the location of the 363*94eb5533SMasatake YAMATOtag file instead of the current directory. For standard vi, which always 364*94eb5533SMasatake YAMATOinterprets the paths as relative to the current directory, we need to 365*94eb5533SMasatake YAMATObuild the global tag file with absolute path names. This can be 366*94eb5533SMasatake YAMATOaccomplished by replacing step 2 with the following: 367*94eb5533SMasatake YAMATO 368*94eb5533SMasatake YAMATO cd ~/project 369*94eb5533SMasatake YAMATO ctags --file-scope=no -R `pwd` 370*94eb5533SMasatake YAMATO 371*94eb5533SMasatake YAMATO-- 372