how do I create a ctags file recursively?
Asked Answered
C

4

5

I would like to create a tags file using ctags for a complete source tree. Now I generally would run ctags *.c but the problem is in the top directory, there's no source files. Also, I'd like it to pick up *.c,*.h,*.cpp & *.hpp files, how can I do this?

Charkha answered 27/8, 2016 at 22:14 Comment(2)
ctags --recurse or ctags -R should work. Which version of ctags are you using?Kelsey
@WilliamPursell Ctags 5.9~svn20110310 from the Ubuntu repo and if you add your comment as an answer, I'll accept it as such!Charkha
K
11

You can use ctags --recurse or ctags -R to recursively descend into a directory tree.

Kelsey answered 27/8, 2016 at 22:55 Comment(3)
On Ubuntu 18.04, when I tried this, there was a ctags installed, but it did not support --recurse. I did sudo apt-get install ctags and then this worked fine.Tumescent
be aware that emacs-ctags does not have a --recurse, verbose (-v) will should the vendor or check the help output to see if it has recurseSalesgirl
-R is ignore regex in ctags (GNU Emacs 27.2)Licha
A
3

If you want to generate tags for c/c++/javascript/java/python files present in your git repo (respecting .gitignore) :

git ls-files | ctags --links=no --languages=c,c++,javascript,java,python -L- 
Arbitrate answered 30/9, 2019 at 9:58 Comment(0)
A
0

If you don't have any source in the root directory, the best way to filter is with the --languages option. Here's one I used for a mixed-language project, where I only wanted tags for the Tcl files.

ctags -R --languages=Tcl .

Note, if you need support for multiple languages, you can add them with ,

To see the list of languages, use --list-languages

Aristotelian answered 14/3, 2018 at 13:34 Comment(0)
K
0

You can use ctags -R or stags --recurse, as others have suggested.

However, as mentioned by user cxw, this doesn't work on Ubuntu 18.04.

Here's what I found. The default install has:

# ctags --version
ctags (GNU Emacs 25.2)
Copyright (C) 2017 Free Software Foundation, Inc.
This program is distributed under the terms in ETAGS.README

Then, after sudo apt-get install ctags, I get:

# ctags --version
Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009 Darren Hiebert
  Addresses: <[email protected]>, http://ctags.sourceforge.net
  Optional compiled features: +wildcards, +regex

And now the recurse option works.

Knucklebone answered 13/10, 2020 at 18:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.