How to create ctags only for c and h files in code
Asked Answered
S

3

12

I have a compiled code. If i try generation the tags using the 'usr/bin/ctags -R *', it will include all the c,h,object files etc. So it is taking lot of time and also memory. Could you please let me know how to generate tags only for c/h files.

Sensible answered 2/5, 2013 at 5:26 Comment(0)
A
20

Use the --languages parameter:

ctags --languages=C

Arquebus answered 23/1, 2014 at 12:44 Comment(2)
--languages only can read .c file, but not .h file, it should use: ctags -h=".c.h"Strictly
--languages only includes .c, so you need to also include c++ "--languages=C,C++" which will add .h files as well as several c++ file extensions. ".h" files have to be processed as C++ since it is a superset and you can't assume they only use C language featuresPsittacine
E
2

You can use a .ctagsignore file to exclude any unwanted files from the generated tags. The following is an example I use for my projects:

Contents of .ctagsignore:

bin
makefile
obj
tags
workspace.vim

And then generate tags with: -ctags -R [email protected]

This ignores every file in the bin, and obj folder, the makefile, the (future) generated tags file, and the workspace.vim file in the project directory. It essentially works like a .gitignore file, so you can use the wildcard (*.o) notation - myfolder/*.o ignores all object files in $PROJ_DIR$/myfolder/

European answered 19/3, 2020 at 19:38 Comment(0)
M
0

i would try 'man ctags' and read thru the options.

or you can use shell magic like:

ctags `find . -name "*.[ch]" -print` 

or something like that

Mong answered 2/5, 2013 at 5:29 Comment(1)
I feel this is the best option.Nyberg

© 2022 - 2024 — McMap. All rights reserved.