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?
You can use ctags --recurse
or ctags -R
to recursively descend into a directory tree.
ctags
installed, but it did not support --recurse
. I did sudo apt-get install ctags
and then this worked fine. –
Tumescent --recurse
, verbose (-v
) will should the vendor or check the help output to see if it has recurse –
Salesgirl 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-
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
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.
© 2022 - 2024 — McMap. All rights reserved.
ctags --recurse
orctags -R
should work. Which version of ctags are you using? – KelseyCtags 5.9~svn20110310
from the Ubuntu repo and if you add your comment as an answer, I'll accept it as such! – Charkha