用ctags看代码时,检索函数及变量使用的文件是tags文件,有时我们会定制检索的文件范围,这时候就可以通过ctags命令的一些参数来控制tags文件的内容
1:递归检索当前目录以下所有默认要检索的文件
ctags -R
2:递归检索当前目录以下所有默认要检索的文件,且检索被#if 0包含的内容
ctags -R --if0=yes
3:递归检索当前目录以下所有c c++ java类型的文件,如c++类型的文件可以通过ctags --list-maps=c++得到
ctags --languages=c,c++,java -R
4:递归检索指定目录(含文件)下的c c++ java类型的文件
ctags --languages=c,c++,java --exclude=kerne* --exclude=lk* -R //排除kerne*及lk*表示的文件及文件夹
ctags --languages=c,c++,java kerne* lk* -R //只检索kerne*及lk*表示的文件及文件夹
备注说明:
ctags中的几个概念
1:ctags中支持的languages ,规定支持了很多种语言,并且将每种语言有若干种特定的后缀表示的文件,
如c语言,凡是*.c后缀的都是c语言
如 C++ *.c++ *.cc *.cp *.cpp *.cxx *.h *.h++*.hh *.hp *.hpp *.hxx *.C *.H
2:kinds 每种语言都支持检索若干种类型的字符(串),比如c语言支持检索变量,函数
如
C
c classes
d macro definitions
e enumerators (values inside an enumeration)
f function definitions
g enumeration names
l local variables [off]
m class, struct, and union members
n namespaces
p function prototypes [off]
s structure names
t typedefs
u union names
v variable definitions
x external and forward variable declarations [off]
ctags详细参数如下
ctags --help
Exuberant Ctags 5.9~svn20110310, Copyright (C) 1996-2009Darren Hiebert
Compiled: Oct 7 2014, 13:52:03
Addresses: <dhiebert@users.sourceforge.net>,http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
Usage: ctags [options] [file(s)]
-a Append the tags to an existing tag file.
-B Use backward searching patterns (?...?).
-e Output tag file for use with Emacs.
-f <name>
Write tags to specified file.Value of "-" writes tags to stdout
["tags"; or"TAGS" when -e supplied].
//生成的tags以name命名
-F Use forward searching patterns (/.../)(default).
-h <list>
Specify list of file extensions tobe treated as include files.
[".h.H.hh.hpp.hxx.h++"].
//将list文件作为包含文件 ctags –h .h++ -R
-I <list|@file>
A list of tokens to be speciallyhandled is read from either the
command line or the specified file.
-L <file>
A list of source file names areread from the specified file.
If specified as "-", thenstandard input is read.
-n Equivalent to --excmd=number.
-N Equivalent to --excmd=pattern.
-o Alternative for -f.
-R Equivalent to --recurse.
-u Equivalent to --sort=no.
-V Equivalent to --verbose.
-x Print a tabular cross reference file tostandard output.
--append=[yes|no]
Should tags should be appended toexisting tag file [no]?
//是否将tags追加到存在的tags文件中
//如ctags --languages=c++ -R //tags中只有C++,h文件的索引
//ctags --languages=c -R --append=yes //tags中有C++,h和C文件的索引
--etags-include=file
Include reference to 'file' inEmacs-style tag file (requires -e).
--exclude=pattern
Exclude files and directories matching'pattern'.
//将符合模式'pattern'的文件或目录排除在ctags生成检索文件之列
//ctags--languages=c,c++ -R –exclude=*.cpp//检索文件为c,c++语言,且排除*.cpp表示的文件及文件夹
//ctags--languages=c,c++ -R –exclude=kerne* //检索文件为c,c++语言,且排除kerne*表示的文件及文件夹
--excmd=number|pattern|mix
Uses the specified type of EXcommand to locate tags [mix].
--extra=[+|-]flags
Include extra tag entries for selectedinformation (flags: "fq").
--fields=[+|-]flags
Include selected extension fields(flags: "afmikKlnsStz") [fks].
--file-scope=[yes|no]
Should tags scoped only for asingle file (e.g. "static" tags
be included in the output [yes]?
--filter=[yes|no]
Behave as a filter, reading filenames from standard input and
writing tags to standard output[no].
--filter-terminator=string
Specify string to print to stdoutfollowing the tags for each file
parsed when --filter is enabled.
--format=level
Force output of specified tag fileformat [2].
--help
Print this option summary.
--if0=[yes|no]
Should C code within #if 0conditional branches be parsed [no]?
//检索if 0包含的内容
--<LANG>-kinds=[+|-]kinds
Enable/disable tag kinds forlanguage <LANG>.
--langdef=name
Define a new language to be parsedwith regular expressions.
--langmap=map(s)
Override default mapping oflanguage to source file extension.
--language-force=language
Force all files to be interpretedusing specified language.
--languages=[+|-]list
Restrict files scanned for tags tothose mapped to langauges
specified in the comma-separated'list'. The list can contain any
built-in or user-defined language[all].
//限制检索的语言列表
//ctags--languages=-c,c++ -R//不检索c c++ h语言
//ctags--languages=c,c++ -R //只检索c c++ h语言
--license
Print details of software license.
--line-directives=[yes|no]
Should #line directives beprocessed [no]?
--links=[yes|no]
Indicate whether symbolic linksshould be followed [yes].
--list-kinds=[language|all]
Output a list of all tag kinds forspecified language or all.
//列出所有能检索到的内容
--list-languages
Output list of supported languages.
//支持的检索语言
--list-maps=[language|all]
Output list of language mappings.
//列出所有语言对应的文件后缀,如 C++ *.c++ *.cc *.cp *.cpp *.cxx *.h *.h++*.hh *.hp *.hpp *.hxx *.C *.H
//表示这些后缀的文件都是c++语言的文件,ctags --languages=c++ -R 都回检索这些后缀的文件
--options=file
Specify file from which commandline options should be read.
--recurse=[yes|no]
Recurse into directories suppliedon command line [no].
--regex-<LANG>=/line_pattern/name_pattern/[flags]
Define regular expression forlocating tags in specific language.
--sort=[yes|no|foldcase]
Should tags be sorted (optionallyignoring case) [yes]?.
//对检索生成的文件内容分类
--tag-relative=[yes|no]
Should paths be relative tolocation of tag file [no; yes when -e]?
--totals=[yes|no]
Print statistics about source andtag files [no].
--verbose=[yes|no]
Enable verbose messages describingactions on each source file.
//输出检索记录
--version
Print version identifier tostandard output.
ctags详细参数如下
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)