stdcerr
stdcerr

Reputation: 15608

how do I create a ctags file recursively?

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?

Upvotes: 5

Views: 14374

Answers (4)

Brian
Brian

Reputation: 2242

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.

Upvotes: 0

me_astr
me_astr

Reputation: 1042

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- 

Upvotes: 3

Dustin Williams
Dustin Williams

Reputation: 11

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

Upvotes: 0

William Pursell
William Pursell

Reputation: 212268

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

Upvotes: 11

Related Questions