xref: /Universal-ctags/man/ctags-faq.7.rst.in (revision 1db5cd667e8dc1fdd1a4f98cd5e04bba7114ad85)
1b1b89522SHiroo HAYASHI.. _ctags-faq(7):
282f75a99SHiroo HAYASHI
3b1b89522SHiroo HAYASHI==============================================================
4b1b89522SHiroo HAYASHIctags-faq
5b1b89522SHiroo HAYASHI==============================================================
6b1b89522SHiroo HAYASHI--------------------------------------------------------------
7b1b89522SHiroo HAYASHIUniversal Ctags FAQ
8b1b89522SHiroo HAYASHI--------------------------------------------------------------
9b1b89522SHiroo HAYASHI:Version: @VERSION@
10b1b89522SHiroo HAYASHI:Manual group: Universal Ctags
11b1b89522SHiroo HAYASHI:Manual section: 7
1282f75a99SHiroo HAYASHI
13b1b89522SHiroo HAYASHIThis is the Universal Ctags FAQ (Frequently-Asked Questions).
14b1b89522SHiroo HAYASHIIt is based on `Exuberant Ctags FAQ <http://ctags.sourceforge.net/faq.html>`_
15b1b89522SHiroo HAYASHI
16b1b89522SHiroo HAYASHI.. contents::
17b1b89522SHiroo HAYASHI
18b1b89522SHiroo HAYASHIDESCRIPTION
19b1b89522SHiroo HAYASHI-----------
20b1b89522SHiroo HAYASHI
21b726979aSHiroo HAYASHI.. TODO: https://github.com/universal-ctags/ctags/issues/2312
22b726979aSHiroo HAYASHI	#1421: feature: clean up stale tags when appending (`-a`)
23b726979aSHiroo HAYASHI	#2356: can't pre-process the macro but it works with Exuberant Ctags 5.8
24b726979aSHiroo HAYASHI	#2540: C/C++:conditional compilation like #ifdef will cause parse errror
25b726979aSHiroo HAYASHI
26*1db5cd66SHiroo HAYASHIWhat is the difference between Universal Ctags and Exuberant Ctags?
27*1db5cd66SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28*1db5cd66SHiroo HAYASHI
29*1db5cd66SHiroo HAYASHIUniversal Ctags is an unofficial fork of Exuberant Ctags.
30*1db5cd66SHiroo HAYASHIThe differences are summarized in ctags-incompatibilities(7) man page.
31*1db5cd66SHiroo HAYASHI
32*1db5cd66SHiroo HAYASHIThe most notable one is that Universal Ctags doesn't read ``~/.ctags`` file.
33*1db5cd66SHiroo HAYASHIInstead, it reads ``*.ctags`` under ``~/.ctags.d`` directory.
34*1db5cd66SHiroo HAYASHI
35*1db5cd66SHiroo HAYASHIHow can I avoid having to specify my favorite option every time?
36*1db5cd66SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37*1db5cd66SHiroo HAYASHI
38*1db5cd66SHiroo HAYASHIEither by setting the environment variable ``CTAGS`` to your custom
39*1db5cd66SHiroo HAYASHIoptions, or putting them into a ``~/.ctags.d/anyname.ctags`` file in your home
40*1db5cd66SHiroo HAYASHIdirectory.
41*1db5cd66SHiroo HAYASHI
429bab2899SHiroo HAYASHIWhat are these strange bits of text beginning with ``;"`` which follow many of the lines in the tag file?
439bab2899SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4482f75a99SHiroo HAYASHI
459bab2899SHiroo HAYASHIThese are *extension flags*. They are added in order to provide extra
4682f75a99SHiroo HAYASHIinformation about the tag that may be utilized by the editor in order to
4782f75a99SHiroo HAYASHImore intelligently handle tags. They are appended to the EX command part of
4882f75a99SHiroo HAYASHIthe tag line in a manner that provides backwards compatibility with existing
4982f75a99SHiroo HAYASHIimplementations of the Vi editor. The semicolon is an EX command separator
5082f75a99SHiroo HAYASHIand the double quote begins an EX comment. Thus, the extension flags appear
5182f75a99SHiroo HAYASHIas an EX comment and should be ignored by the editor when it processes the
5282f75a99SHiroo HAYASHIEX command.
5382f75a99SHiroo HAYASHI
5482f75a99SHiroo HAYASHISome non-vi editors, however, implement only the bare minimum of EX commands
5582f75a99SHiroo HAYASHIin order to process the search command or line number in the third field of
569bab2899SHiroo HAYASHIthe tag file. If you encounter this problem, use the option ``--format=1`` to
5782f75a99SHiroo HAYASHIgenerate a tag file without these extensions (remember that you can set the
5882f75a99SHiroo HAYASHICTAGS environment variable to any default arguments you wish to supply). Then
5982f75a99SHiroo HAYASHIask the supplier of your editor to implement handling of this feature of EX
6082f75a99SHiroo HAYASHIcommands.
6182f75a99SHiroo HAYASHI
629bab2899SHiroo HAYASHIWhy can't I jump to ``class::member``?
63b1b89522SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6482f75a99SHiroo HAYASHI
6582f75a99SHiroo HAYASHIBecause, by default, ctags only generates tags for the separate identifiers
669bab2899SHiroo HAYASHIfound in the source files. If you specify the ``--extra=+q`` option, then
6782f75a99SHiroo HAYASHIctags will also generate a second, class-qualified tag for each class member
689bab2899SHiroo HAYASHI(data and function/method) in the form ``class::member`` for C++, and in the form
699bab2899SHiroo HAYASHI``class.method`` for Eiffel and Java.
7082f75a99SHiroo HAYASHI
71b1b89522SHiroo HAYASHIWhy do I end up on the wrong line when I jump to a tag?
72b1b89522SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7382f75a99SHiroo HAYASHI
749bab2899SHiroo HAYASHIBy default, ctags encodes the line number in the file where macro (``#define``)
7582f75a99SHiroo HAYASHItags are found. This was done to remain compatible with the original UNIX
7682f75a99SHiroo HAYASHIversion of ctags. If you change the file containing the tag without
7782f75a99SHiroo HAYASHIrebuilding the tag file, the location of tag in the tag file may no longer
7882f75a99SHiroo HAYASHImatch the current location.
7982f75a99SHiroo HAYASHI
809bab2899SHiroo HAYASHIIn order to avoid this problem, you can specify the option ``--excmd=p``,
8182f75a99SHiroo HAYASHIwhich causes ctags to use a search pattern to locate macro tags. I have
8282f75a99SHiroo HAYASHInever uncovered the reason why the original UNIX ctags used line numbers
8382f75a99SHiroo HAYASHIexclusively for macro tags, but have so far resisted changing the default
849bab2899SHiroo HAYASHIbehavior of Exuberant (and Universal) Ctags to behave differently.
8582f75a99SHiroo HAYASHI
86b1b89522SHiroo HAYASHIHow do I jump to the tag I want instead of the wrong one by the same name?
87b1b89522SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8882f75a99SHiroo HAYASHI
8982f75a99SHiroo HAYASHIA tag file is simple a list of tag names and where to find them. If there
9082f75a99SHiroo HAYASHIare duplicate entries, you often end up going to the wrong one because the
9182f75a99SHiroo HAYASHItag file is sorted and your editor locates the first one in the tag file.
9282f75a99SHiroo HAYASHI
9382f75a99SHiroo HAYASHIStandard Vi provides no facilities to alter this behavior. However, Vim
949bab2899SHiroo HAYASHIhas some nice features to minimize this problem, primarily by examining all
9582f75a99SHiroo HAYASHImatches and choosing the best one under the circumstances. Vim also provides
9682f75a99SHiroo HAYASHIcommands which allow for selection of the desired matching tag.
9782f75a99SHiroo HAYASHI
98b1b89522SHiroo HAYASHIHow can I locate all references to a specific function or variable?
99b1b89522SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10082f75a99SHiroo HAYASHI
10182f75a99SHiroo HAYASHIThere are several packages already available which provide this capability.
10282f75a99SHiroo HAYASHINamely, these are: GLOBAL source code tag system, GNU id-utils, cscope,
10382f75a99SHiroo HAYASHIand cflow. As of this writing, they can be found in the following locations:
10482f75a99SHiroo HAYASHI
105b1b89522SHiroo HAYASHI- GLOBAL:    http://www.gnu.org/software/global
106b1b89522SHiroo HAYASHI- id-utils:  http://www.gnu.org/software/idutils/idutils.html
107b1b89522SHiroo HAYASHI- cscope:    http://cscope.sourceforge.net
108b1b89522SHiroo HAYASHI- cflow:     ftp://www.ibiblio.org/pub/Linux/devel/lang/c
10982f75a99SHiroo HAYASHI
110b1b89522SHiroo HAYASHIWhy does appending tags to a tag file tag so long?
111b1b89522SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11282f75a99SHiroo HAYASHI
11382f75a99SHiroo HAYASHISometimes, in an attempt to build a global tag file for all source files in
11482f75a99SHiroo HAYASHIa large source tree of many directories, someone will make an attempt to run
1159bab2899SHiroo HAYASHIctags in append (``-a``) mode on every directory in the hierarchy. Each time
11682f75a99SHiroo HAYASHIctags is invoked, its default behavior is to sort the tag file once the tags
11782f75a99SHiroo HAYASHIfor that execution have been added. As the cumulative tag file grows, the sort
11882f75a99SHiroo HAYASHItime increases arithmetically.
11982f75a99SHiroo HAYASHI
12082f75a99SHiroo HAYASHIThe best way to avoid this problem (and the most efficient) is to make
1219bab2899SHiroo HAYASHIuse of the ``--recurse`` (or ``-R``) option of ctags by executing the following
12282f75a99SHiroo HAYASHIcommand in the root of the directory hierarchy (thus running ctags only once):
12382f75a99SHiroo HAYASHI
124b1b89522SHiroo HAYASHI	.. code-block:: sh
125b1b89522SHiroo HAYASHI
12682f75a99SHiroo HAYASHI		ctags -R
12782f75a99SHiroo HAYASHI
12882f75a99SHiroo HAYASHIIf you really insist on running ctags separately on each directory, you can
1299bab2899SHiroo HAYASHIavoid the sort pass each time by specifying the option ``--sort=no``. Once the
13082f75a99SHiroo HAYASHItag file is completely built, use the sort command to manually sort the
13182f75a99SHiroo HAYASHIfinal tag file, or let the final invocation of ctags sort the file.
13282f75a99SHiroo HAYASHI
133b1b89522SHiroo HAYASHIHow should I set up tag files for a multi-level directory hierarchy?
134b1b89522SHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13582f75a99SHiroo HAYASHI
13682f75a99SHiroo HAYASHIThere are a few ways of approaching this:
13782f75a99SHiroo HAYASHI
13882f75a99SHiroo HAYASHI1.  A local tag file in each directory containing only the tags for source
13982f75a99SHiroo HAYASHI    files in that directory.
14082f75a99SHiroo HAYASHI
14182f75a99SHiroo HAYASHI2.  One single big, global tag file present in the root directory of your
14282f75a99SHiroo HAYASHI    hierarchy, containing all tags present in all source files in the
14382f75a99SHiroo HAYASHI    hierarchy.
14482f75a99SHiroo HAYASHI
14582f75a99SHiroo HAYASHI3.  A local tag file in each directory containing only the tags for source
14682f75a99SHiroo HAYASHI    files in that directory, in addition to one single global tag file
14782f75a99SHiroo HAYASHI    present in the root directory of your hierarchy, containing all
14882f75a99SHiroo HAYASHI    non-static tags present in all source files in the hierarchy.
14982f75a99SHiroo HAYASHI
15082f75a99SHiroo HAYASHI4.  A local tag file in each directory of the hierarchy, each one
15182f75a99SHiroo HAYASHI    containing all tags present in source files in that directory and all
15282f75a99SHiroo HAYASHI    non-static tags in every directory below it (note that this implies
15382f75a99SHiroo HAYASHI    also having one big tag file in the root directory of the hierarchy).
15482f75a99SHiroo HAYASHI
15582f75a99SHiroo HAYASHIEach of these approaches has its own set of advantages and disadvantages,
15682f75a99SHiroo HAYASHIdepending upon your particular conditions. Which approach is deemed best
15782f75a99SHiroo HAYASHIdepends upon the following factors:
15882f75a99SHiroo HAYASHI
15982f75a99SHiroo HAYASHIA.  The ability of your editor to use multiple tag files.
16082f75a99SHiroo HAYASHI
16182f75a99SHiroo HAYASHI    If your editor cannot make use of multiple tag files (original vi
16282f75a99SHiroo HAYASHI    implementations could not), then one large tag file is the only way to
16382f75a99SHiroo HAYASHI    go if you ever desire to jump to tags located in other directories. If
16482f75a99SHiroo HAYASHI    you never need to jump to tags in another directory (i.e. the source
16582f75a99SHiroo HAYASHI    in each directory is entirely self-contained), then a local tag file
16682f75a99SHiroo HAYASHI    in each directory will fit your needs.
16782f75a99SHiroo HAYASHI
16882f75a99SHiroo HAYASHIB.  The time is takes for your editor to look up a tag in the tag file.
16982f75a99SHiroo HAYASHI
17082f75a99SHiroo HAYASHI    The significance of this factor depends upon the size of your source
17182f75a99SHiroo HAYASHI    tree and on whether the source files are located on a local or remote
17282f75a99SHiroo HAYASHI    file system. For source and tag files located on a local file system,
17382f75a99SHiroo HAYASHI    looking up a tag is not as big a hit as one might first imagine, since
17482f75a99SHiroo HAYASHI    vi implementations typically perform a binary search on a sorted tag
17582f75a99SHiroo HAYASHI    file. This may or may not be true for the editor you use. For files
17682f75a99SHiroo HAYASHI    located on a remote file system, reading a large file is an expensive
17782f75a99SHiroo HAYASHI    operation.
17882f75a99SHiroo HAYASHI
17982f75a99SHiroo HAYASHIC.  Whether or not you expect the source code to change and the time it
18082f75a99SHiroo HAYASHI    takes to rebuild a tag file to account for changes to the source code.
18182f75a99SHiroo HAYASHI
1829bab2899SHiroo HAYASHI    While Universal Ctags is particularly fast in scanning source code
18382f75a99SHiroo HAYASHI    (around 1-2 MB/sec), a large project may still result in objectionable
18482f75a99SHiroo HAYASHI    delays if one wishes to keep their tag file(s) up to date on a
18582f75a99SHiroo HAYASHI    frequent basis, or if the files are located on a remote file system.
18682f75a99SHiroo HAYASHI
18782f75a99SHiroo HAYASHID.  The presence of duplicate tags in the source code and the ability to
18882f75a99SHiroo HAYASHI    handle them.
18982f75a99SHiroo HAYASHI
19082f75a99SHiroo HAYASHI    The impact of this factor is influenced by the following three issues:
19182f75a99SHiroo HAYASHI
19282f75a99SHiroo HAYASHI    1.  How common are duplicate tags in your project?
19382f75a99SHiroo HAYASHI
19482f75a99SHiroo HAYASHI    2.  Does your editor provide any facilities for dealing with duplicate
19582f75a99SHiroo HAYASHI        tags?
19682f75a99SHiroo HAYASHI
19782f75a99SHiroo HAYASHI        While standard vi does not, many modern vi implementations, such
19882f75a99SHiroo HAYASHI        as Vim have good facilities for selecting the desired match from
19982f75a99SHiroo HAYASHI        the list of duplicates. If your editor does not support duplicate
20082f75a99SHiroo HAYASHI        tags, then it will typically send you to only one of them, whether
20182f75a99SHiroo HAYASHI        or not that is the one you wanted (and not even notifying you that
20282f75a99SHiroo HAYASHI        there are other potential matches).
20382f75a99SHiroo HAYASHI
20482f75a99SHiroo HAYASHI    3.  What is the significance of duplicate tags?
20582f75a99SHiroo HAYASHI
20682f75a99SHiroo HAYASHI        For example, if you have two tags of the same name from entirely
20782f75a99SHiroo HAYASHI        isolated software components, jumping first to the match found
20882f75a99SHiroo HAYASHI        in component B while working in component A may be entirely
20982f75a99SHiroo HAYASHI        misleading, distracting or inconvenient (to keep having to choose
21082f75a99SHiroo HAYASHI        which one if your editor provides you with a list of matches).
21182f75a99SHiroo HAYASHI        However, if you have two tags of the same name for parallel builds
21282f75a99SHiroo HAYASHI        (say two initialization routines for different hosts), you may
21382f75a99SHiroo HAYASHI        always want to specify which one you want.
21482f75a99SHiroo HAYASHI
21582f75a99SHiroo HAYASHIOf the approaches listed above, I tend to favor Approach 3. My editor of
21682f75a99SHiroo HAYASHIchoice is Vim, which provides a rich set of features for handling multiple
21782f75a99SHiroo HAYASHItag files, which partly influences my choice. If you are working with
21882f75a99SHiroo HAYASHIsource files on a remote file system, then I would recommend either
21982f75a99SHiroo HAYASHIApproach 3 or Approach 4, depending upon the hit when reading the global
22082f75a99SHiroo HAYASHItag file.
22182f75a99SHiroo HAYASHI
22282f75a99SHiroo HAYASHIThe advantages of Approach 3 are many (assuming that your editor has
22382f75a99SHiroo HAYASHIthe ability to support both multiple tag files and duplicate tags). All
2249bab2899SHiroo HAYASHIlookups of tag located in the current directory are fast and the local
22582f75a99SHiroo HAYASHItag file can be quickly and easily regenerated in one second or less
22682f75a99SHiroo HAYASHI(I have even mapped a keystroke to do this easily). A lookup of a
22782f75a99SHiroo HAYASHI(necessarily non-static) tag found in another directory fails a lookup in
22882f75a99SHiroo HAYASHIthe local tag file, but is found in the global tag file, which satisfies
22982f75a99SHiroo HAYASHIall cross-directory lookups. The global tag file can be automatically
23082f75a99SHiroo HAYASHIregenerated periodically with a cron job (and perhaps the local tag files
23182f75a99SHiroo HAYASHIalso).
23282f75a99SHiroo HAYASHI
23382f75a99SHiroo HAYASHINow I give an example of how you would implement Approach 3. Means of
23482f75a99SHiroo HAYASHIimplementing the other approaches can be performed in a similar manner.
23582f75a99SHiroo HAYASHI
23682f75a99SHiroo HAYASHIHere is a visual representation of an example directory hierarchy:
23782f75a99SHiroo HAYASHI
238b1b89522SHiroo HAYASHI::
239b1b89522SHiroo HAYASHI
24082f75a99SHiroo HAYASHI	project
24182f75a99SHiroo HAYASHI	`-----misccomp
24282f75a99SHiroo HAYASHI	|       `...
24382f75a99SHiroo HAYASHI	`-----sysint
24482f75a99SHiroo HAYASHI	        `-----client
24582f75a99SHiroo HAYASHI	        |       `-----hdrs
24682f75a99SHiroo HAYASHI	        |       `-----lib
24782f75a99SHiroo HAYASHI	        |       `-----src
24882f75a99SHiroo HAYASHI	        |       `-----test
24982f75a99SHiroo HAYASHI	        `-----common
25082f75a99SHiroo HAYASHI	        |       `-----hdrs
25182f75a99SHiroo HAYASHI	        |       `-----lib
25282f75a99SHiroo HAYASHI	        |       `-----src
25382f75a99SHiroo HAYASHI	        |       `-----test
25482f75a99SHiroo HAYASHI	        `-----server
25582f75a99SHiroo HAYASHI	                `-----hdrs
25682f75a99SHiroo HAYASHI	                `-----lib
25782f75a99SHiroo HAYASHI	                `-----src
25882f75a99SHiroo HAYASHI	                `-----test
25982f75a99SHiroo HAYASHI
26082f75a99SHiroo HAYASHIHere is a recommended solution (conceptually) to build the tag files:
26182f75a99SHiroo HAYASHI
2629bab2899SHiroo HAYASHI1.  Within each of the leaf nodes (i.e. ``hdrs``, ``lib``, ``src``, ``test``) build a tag
263b1b89522SHiroo HAYASHI    file using "``ctags *.[ch]``". This can be easily be done for the whole
2649bab2899SHiroo HAYASHI    hierarchy by making a shell script, call it ``dirtags``, containing the
26582f75a99SHiroo HAYASHI    following lines:
26682f75a99SHiroo HAYASHI
267b1b89522SHiroo HAYASHI	.. code-block:: sh
268b1b89522SHiroo HAYASHI
26982f75a99SHiroo HAYASHI		#!/bin/sh
27082f75a99SHiroo HAYASHI		cd $1
27182f75a99SHiroo HAYASHI		ctags *
27282f75a99SHiroo HAYASHI
27382f75a99SHiroo HAYASHI    Now execute the following command:
27482f75a99SHiroo HAYASHI
275b1b89522SHiroo HAYASHI	.. code-block:: sh
276b1b89522SHiroo HAYASHI
27782f75a99SHiroo HAYASHI		find * -type d -exec dirtags {} \;
27882f75a99SHiroo HAYASHI
27982f75a99SHiroo HAYASHI    These tag files are trivial (and extremely quick) to rebuild while
28082f75a99SHiroo HAYASHI    making changes within a directory. The following Vim key mapping is
28182f75a99SHiroo HAYASHI    quite useful to rebuild the tag file in the directory of the current
28282f75a99SHiroo HAYASHI    source file:
28382f75a99SHiroo HAYASHI
284b1b89522SHiroo HAYASHI	.. code-block:: text
285b1b89522SHiroo HAYASHI
28682f75a99SHiroo HAYASHI		:nmap ,t :!(cd %:p:h;ctags *.[ch])&<CR><CR>
28782f75a99SHiroo HAYASHI
28882f75a99SHiroo HAYASHI2.  Build the global tag file:
28982f75a99SHiroo HAYASHI
290b1b89522SHiroo HAYASHI	.. code-block:: sh
291b1b89522SHiroo HAYASHI
29282f75a99SHiroo HAYASHI		cd ~/project
29382f75a99SHiroo HAYASHI		ctags --file-scope=no -R
29482f75a99SHiroo HAYASHI
29582f75a99SHiroo HAYASHI    thus constructing a tag file containing only non-static tags for all
29682f75a99SHiroo HAYASHI    source files in all descendent directories.
29782f75a99SHiroo HAYASHI
29882f75a99SHiroo HAYASHI3.  Configure your editor to read the local tag file first, then consult
29982f75a99SHiroo HAYASHI    the global tag file when not found in the local tag file. In Vim,
30082f75a99SHiroo HAYASHI    this is done as follows:
30182f75a99SHiroo HAYASHI
302b1b89522SHiroo HAYASHI	.. code-block:: text
303b1b89522SHiroo HAYASHI
30482f75a99SHiroo HAYASHI		:set tags=./tags,tags,~/project/tags
30582f75a99SHiroo HAYASHI
30682f75a99SHiroo HAYASHIIf you wish to implement Approach 4, you would need to replace the
3079bab2899SHiroo HAYASHI``dirtags`` script of step 1 with the following:
30882f75a99SHiroo HAYASHI
309b1b89522SHiroo HAYASHI	.. code-block:: sh
310b1b89522SHiroo HAYASHI
31182f75a99SHiroo HAYASHI		#!/bin/sh
31282f75a99SHiroo HAYASHI		cd $1
31382f75a99SHiroo HAYASHI		ctags *
31482f75a99SHiroo HAYASHI		# Now append the non-static tags from descendent directories
31582f75a99SHiroo HAYASHI		find * -type d -prune -print | ctags -aR --file-scope=no -L-
31682f75a99SHiroo HAYASHI
31782f75a99SHiroo HAYASHIAnd replace the configuration of step 3 with this:
31882f75a99SHiroo HAYASHI
319b1b89522SHiroo HAYASHI	.. code-block:: text
320b1b89522SHiroo HAYASHI
32182f75a99SHiroo HAYASHI		:set tags=./tags;$HOME,tags
32282f75a99SHiroo HAYASHI
32382f75a99SHiroo HAYASHIAs a caveat, it should be noted that step 2 builds a global tag file whose
32482f75a99SHiroo HAYASHIfile names will be relative to the directory in which the global tag file
3259bab2899SHiroo HAYASHIis being built. This takes advantage of the Vim ``tagrelative`` option,
32682f75a99SHiroo HAYASHIwhich causes the path to be interpreted a relative to the location of the
32782f75a99SHiroo HAYASHItag file instead of the current directory. For standard vi, which always
32882f75a99SHiroo HAYASHIinterprets the paths as relative to the current directory, we need to
32982f75a99SHiroo HAYASHIbuild the global tag file with absolute path names. This can be
33082f75a99SHiroo HAYASHIaccomplished by replacing step 2 with the following:
33182f75a99SHiroo HAYASHI
332b1b89522SHiroo HAYASHI	.. code-block:: sh
333b1b89522SHiroo HAYASHI
33482f75a99SHiroo HAYASHI		cd ~/project
33582f75a99SHiroo HAYASHI		ctags --file-scope=no -R `pwd`
33682f75a99SHiroo HAYASHI
337b726979aSHiroo HAYASHIDoes Universal Ctags support Unicode file names?
338b726979aSHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339b726979aSHiroo HAYASHI
340b726979aSHiroo HAYASHI.. MEMO: from https://github.com/universal-ctags/ctags/issues/1837
341b726979aSHiroo HAYASHI
342b726979aSHiroo HAYASHIYes, Unicode file names are supported on unix-like platforms (Linux, macOS,
343b726979aSHiroo HAYASHICygwin, etc.).
344b726979aSHiroo HAYASHI
345b726979aSHiroo HAYASHIHowever, on Windows, you need to use Windows 10 version 1903 or later to use
346b726979aSHiroo HAYASHIUnicode file names. (This is an experimental feature, though.) On older versions
347b726979aSHiroo HAYASHIon Windows, Universal Ctags only support file names represented in the current
348b726979aSHiroo HAYASHIcode page. If you still want to use Unicode file names on them, use Cygwin or
349b726979aSHiroo HAYASHIMSYS2 version of Universal Ctags as a workaround.
350b726979aSHiroo HAYASHI
351b726979aSHiroo HAYASHIWhy does zsh cause "zsh: no matches found" error?
352b726979aSHiroo HAYASHI~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
353b726979aSHiroo HAYASHI
354b726979aSHiroo HAYASHI.. MEMO: from https://github.com/universal-ctags/ctags/issues/2842
355b726979aSHiroo HAYASHI
356b726979aSHiroo HAYASHIzsh causes error on the following cases;
357b726979aSHiroo HAYASHI
358b726979aSHiroo HAYASHI	.. code-block:: sh
359b726979aSHiroo HAYASHI
360*1db5cd66SHiroo HAYASHI		ctags --extra=+* ...
361b726979aSHiroo HAYASHI		ctags --exclude=foo/* ...
362b726979aSHiroo HAYASHI
363b726979aSHiroo HAYASHIThis is the 2nd most significant incompatibility *feature* of zsh.
364b726979aSHiroo HAYASHI
365b726979aSHiroo HAYASHICited from "Z-Shell Frequently-Asked Questions", "`2.1: Differences from sh and
366b726979aSHiroo HAYASHIksh <http://zsh.sourceforge.net/FAQ/zshfaq02.html>`_";
367b726979aSHiroo HAYASHI
368b726979aSHiroo HAYASHI	... The next most classic difference is that unmatched glob patterns cause
369b726979aSHiroo HAYASHI	the command to abort; set ``NO_NOMATCH`` for those.
370b726979aSHiroo HAYASHI
371b726979aSHiroo HAYASHIYou may add "``setopt nonomatch``" on your ``~/.zshrc``. Or you can escape glob
372b726979aSHiroo HAYASHIpatterns with backslash;
373b726979aSHiroo HAYASHI
374b726979aSHiroo HAYASHI	.. code-block:: sh
375b726979aSHiroo HAYASHI
376*1db5cd66SHiroo HAYASHI		ctags --extra=+\* ...
377b726979aSHiroo HAYASHI		ctags --exclude=foo/\* ...
378b726979aSHiroo HAYASHI
379b726979aSHiroo HAYASHIOr quote them;
380b726979aSHiroo HAYASHI
381b726979aSHiroo HAYASHI	.. code-block:: sh
382b726979aSHiroo HAYASHI
383*1db5cd66SHiroo HAYASHI		ctags '--extra=+*' ...
384b726979aSHiroo HAYASHI		ctags '--exclude=foo/*' ...
385b726979aSHiroo HAYASHI
386b1b89522SHiroo HAYASHISEE ALSO
387b1b89522SHiroo HAYASHI--------
388b1b89522SHiroo HAYASHI
389b1b89522SHiroo HAYASHIThe official Universal Ctags web site at:
390b1b89522SHiroo HAYASHI
391b1b89522SHiroo HAYASHIhttps://ctags.io/
392b1b89522SHiroo HAYASHI
393b1b89522SHiroo HAYASHIctags(1), tags(5)
394b1b89522SHiroo HAYASHI
395b1b89522SHiroo HAYASHIAUTHOR
396b1b89522SHiroo HAYASHI------
397b1b89522SHiroo HAYASHI
398b1b89522SHiroo HAYASHIThis FAQ is based on `Exuberant Ctags FAQ <http://ctags.sourceforge.net/faq.html>`_ by
399b1b89522SHiroo HAYASHIDarren Hiebert and vberthoux@users.sourceforge.net
400b1b89522SHiroo HAYASHI
401b1b89522SHiroo HAYASHIUniversal Ctags project: https://ctags.io/
402