The simplest way in vim would be
:!ctags {.,**}/*.{cpp,h}
Explanation: The braces expand to
:!ctags ./*.cpp **/*.cpp **/*.h **/*.h
So it looks for source or header files in the current directory (./
) or any nested directory (**/
). Note **/
wouldn't match the current directory (it always matches at least 1 sub directory level)
In shell:
find -iname '*.cpp' -o '*.h' -print0 | xargs -0 ctags
Explanation: This recursively finds all .cpp and .h files under the current directory and passes them to ctags
on the command line.
The way print0
and -0
work together is to ensure it works correctly with weird filenames (e.g. containing whitespace or even new line characters)
I'll leave the rest of the ctags options for your own imagination :)
PS. For recent bash-es, you can use
shopt -s globstar
ctags {.,**}/*.{cpp,h}
and get much the same behaviour as in vim !
--language-force=C++
will not pick up the C++ definitions inside the HTML in the first place. Have you verified that? Also, I guess you've seen my answer (I understood the question, I just wanted to challenge the premise a little too) – Sexed