Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'ctags' command is not creating tags for C header files

Tags:

c

vim

ctags

I am trying to create a tag file manually for C sources (*.c and *.h) using ctags command. Unfortunately the tag file is not having entries of all files, specially the header files.

I am using following command on the command prompt:

find . -name \*.[ch] -exec ctags {} \; 

Kindly point out if I am missing some flag or something else above.

like image 582
Vinod Yadav Avatar asked Oct 08 '22 19:10

Vinod Yadav


1 Answers

If you execute (your version):

find . -name \*.[ch] -exec ctags {} \;

then find executes ctags once for each file that is found. The tags file is overwritten each time, and only the tags for the last file remain.

Instead, you need to tell find to execute ctags exactly once, and specify all the matching files in one call. This is how you do that:

find . -name \*.[ch] -exec ctags {} +

OR (I like trojanfoe's version from the comment below because it is easier to read):

ctags $(find . -name \*.[ch])
like image 185
ArjunShankar Avatar answered Oct 12 '22 20:10

ArjunShankar