所有命令行选项使用的官方手册: https://docs.ctags.io/en/latest/man/ctags.1.html#synopsis
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
这些称为 pseudo tags,--pseudo-tags=[+|-](
有4个域,各自包含标识符的信息
查看到的,比如fields域,有些enable是该功能是否使能,我们通过 --fields-c++=+{xx} 就可以来打开fields域对应的xx功能

--_xformat 自己定制xref格式,使用类似printf函数那样的占位符使用
- .\ctags.exe --list-fields
- #LETTER NAME ENABLED LANGUAGE JSTYPE FIXED DESCRIPTION
- N name yes NONE s-- yes tag name
- F input yes NONE s-- yes input file
- P pattern yes NONE s-b yes pattern
- C compact no NONE s-- no compact input line (used only in xref output)
- E extras no NONE s-- no Extra tag type information
- K NONE no NONE s-- no Kind of tag as full name
- R NONE no NONE s-- no Marker (R or D) representing whether tag is definition or reference
- S signature no NONE s-- no Signature of routine (e.g. prototype or parameter list)
- Z scope no NONE s-- no Include the "scope:" key in scope field (use s) in tags output, scope name in xref output
- a access no NONE s-- no Access (or export) of class members
- e end no NONE -i- no end lines of various items
- f file yes NONE --b no File-restricted scoping
- i inherits no NONE s-b no Inheritance information
- k NONE yes NONE s-- no Kind of tag as a single letter
- l language no NONE s-- no Language of input file containing tag
- m implementation no NONE s-- no Implementation information
- n line no NONE -i- no Line number of tag definition
- p scopeKind no NONE s-- no Kind of scope as full name
- r roles no NONE s-- no Roles
- s NONE yes NONE s-- no Scope of tag definition (`p' can be used for printing its kind)
- t typeref yes NONE s-- no Type and name of a variable or typedef
- x xpath no NONE s-- no xpath for the tag
- z kind no NONE s-- no Include the "kind:" key in kind field (use k or K) in tags output, kind full name in xref output
- - properties no AutoIt s-- no properties (static, volatile, ...)
- - macrodef no C s-- no macro definition
- - properties no C s-- no properties (static, inline, mutable,...)
- - captures no C++ s-- no lambda capture list
- - macrodef no C++ s-- no macro definition
- - name yes C++ s-- no aliased names
- - properties no C++ s-- no properties (static, inline, mutable,...)
- - template no C++ s-- no template parameters
- - macrodef no CPreProcessor s-- no macro definition
- - macrodef no CUDA s-- no macro definition
- - properties no CUDA s-- no properties (static, inline, mutable,...)
- - access yes Elixir s-- no access
- - howImported no Go s-- no how the package is imported ("inline" for `.' or "init" for `_')
- - package yes Go s-- no the real package specified by the package name
- - packageName yes Go s-- no the name for referring the package
- - implements yes Inko s-- no Trait being implemented
- - assignment yes LdScript s-- no how a value is assigned to the symbol
- - sectionMarker no Markdown s-- no character used for declaring section(#, ##, =, or -)
- - version no Maven2 s-- no version of artifact
- - wrapping yes Moose s-- no how a wrapper wrapping the method (around, after, or before)
- - langid yes NSIS s-- no language identifier specified in (License)LangString commands
- - category yes ObjectiveC s-- no category attached to the class
- - protocols yes ObjectiveC s-- no protocols that the class (or category) confirms to
- - home yes Passwd s-- no home directory
- - shell yes Passwd s-- no login shell
- - decorators no Python s-- no decorators on functions and classes
- - sectionMarker no ReStructuredText s-- no character used for declaring section
- - uri yes XML s-- no uri associated with name prefix
- .\ctags.exe --list-kinds=c
- d macro definitions
- e enumerators (values inside an enumeration)
- f function definitions
- g enumeration names
- h included header files
- l local variables [off]
- m struct, and union members
- p function prototypes [off]
- s structure names
- t typedefs
- u union names
- v variable definitions
- x external and forward variable declarations [off]
- z function parameters inside function definitions [off]
- L goto labels [off]
- D parameters inside macro definitions [off]
- .\ctags.exe --list-roles=c
- #KIND(L/N) NAME ENABLED DESCRIPTION
- d/macro undef on undefined
- h/header local on local header
- h/header system on system header
- .\ctags.exe --list-extras
- #LETTER NAME ENABLED LANGUAGE FIXED DESCRIPTION
- - anonymous yes NONE no Include tags for non-named objects like lambda
- F fileScope yes NONE no Include tags of file scope
- f inputFile no NONE no Include an entry for the base file name of every input file
- g guest no NONE no Include tags generated by guest parsers
- p pseudo yes NONE no Include pseudo tags
- q qualified no NONE no Include an extra class-qualified tag entry for each tag
- r reference no NONE no Include reference tags
- s subparser yes NONE no Include tags generated by subparsers
- - funcmap yes QemuHX no Include mapping SQMP to C function name
- - whitespaceSwapped yes Robot no Include tags swapping whitespace and underscore chars
从上面的enable列可以看出,有些属性是没有开启的,这里我们用--xx=*,就是开启xx字段的所有属性了,所以这里例子,打印出ctags能记录的所有属性信息
- .\ctags.exe --output-format=json --kinds-all=* --extras=* --fields=* -R
- {"_type": "ptag", "name": "JSON_OUTPUT_VERSION", "path": "0.0", "pattern": "in development"}
- {"_type": "ptag", "name": "TAG_FILE_SORTED", "path": "1", "pattern": "0=unsorted, 1=sorted, 2=foldcase"}
- {"_type": "ptag", "name": "TAG_OUTPUT_FILESEP", "path": "backslash", "pattern": "slash or backslash"}
- {"_type": "ptag", "name": "TAG_PROGRAM_AUTHOR", "path": "Universal Ctags Team", "pattern": ""}
- {"_type": "ptag", "name": "TAG_PROGRAM_NAME", "path": "Universal Ctags", "pattern": "Derived from Exuberant Ctags"}
- {"_type": "ptag", "name": "TAG_PROGRAM_URL", "path": "https://ctags.io/", "pattern": "official site"}
- {"_type": "ptag", "name": "TAG_PROGRAM_VERSION", "path": "0.0.0", "pattern": "fefbad26"}
- {"_type": "tag", "name": "TEST_H", "path": "test.h", "pattern": "/^#define TEST_H$/", "language": "C++", "line": 2, "kind": "macro", "roles": "def", "end": 2}
- {"_type": "tag", "name": "a", "path": "main.c", "pattern": "/^\tint a = 1;$/", "file": true, "language": "C", "line": 9, "typeref": "typename:int", "kind": "local", "roles": "def", "scope": "main", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "a", "path": "test.c", "pattern": "/^int fun(int a, int b)$/", "file": true, "language": "C", "line": 4, "typeref": "typename:int", "kind": "parameter", "roles": "def", "scope": "fun", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "argc", "path": "main.c", "pattern": "/^int main(int argc, char *argv[]) {$/", "file": true, "language": "C", "line": 8, "typeref": "typename:int", "kind": "parameter", "roles": "def", "scope": "main", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "argv", "path": "main.c", "pattern": "/^int main(int argc, char *argv[]) {$/", "file": true, "language": "C", "line": 8, "typeref": "typename:char * []", "kind": "parameter", "roles": "def", "scope": "main", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "b", "path": "main.c", "pattern": "/^\tint b = 2;$/", "file": true, "language": "C", "line": 10, "typeref": "typename:int", "kind": "local", "roles": "def", "scope": "main", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "b", "path": "test.c", "pattern": "/^int fun(int a, int b)$/", "file": true, "language": "C", "line": 4, "typeref": "typename:int", "kind": "parameter", "roles": "def", "scope": "fun", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "c", "path": "main.c", "pattern": "/^int c = 3;$/", "language": "C", "line": 7, "typeref": "typename:int", "kind": "variable", "roles": "def"}
- {"_type": "tag", "name": "d", "path": "main.c", "pattern": "/^\tint d = a+b+c;$/", "file": true, "language": "C", "line": 12, "typeref": "typename:int", "kind": "local", "roles": "def", "scope": "main", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "d", "path": "test.c", "pattern": "/^\tint d = 1;$/", "file": true, "language": "C", "line": 6, "typeref": "typename:int", "kind": "local", "roles": "def", "scope": "fun", "extras": "fileScope", "scopeKind": "function"}
- {"_type": "tag", "name": "fun", "path": "test.c", "pattern": "/^int fun(int a, int b)$/", "language": "C", "line": 4, "signature": "(int a,int b)", "typeref": "typename:int", "kind": "function", "roles": "def", "end": 10}
- {"_type": "tag", "name": "fun", "path": "test.h", "pattern": "/^int fun(int a, int b);$/", "language": "C++", "line": 6, "signature": "(int a,int b)", "typeref": "typename:int", "kind": "prototype", "roles": "def"}
- {"_type": "tag", "name": "main", "path": "main.c", "pattern": "/^int main(int argc, char *argv[]) {$/", "language": "C", "line": 8, "signature": "(int argc,char * argv[])", "typeref": "typename:int", "kind": "function", "roles": "def", "end": 18}
- {"_type": "tag", "name": "main.c", "path": "main.c", "pattern": false, "language": "C", "line": 1, "kind": "file", "roles": "def", "extras": "inputFile", "end": 18}
- {"_type": "tag", "name": "stdio.h", "path": "main.c", "pattern": "/^#include
/" , "language": "C", "line": 1, "kind": "header", "roles": "system", "extras": "reference"} - {"_type": "tag", "name": "stdlib.h", "path": "main.c", "pattern": "/^#include
/" , "language": "C", "line": 2, "kind": "header", "roles": "system", "extras": "reference"} - {"_type": "tag", "name": "test.c", "path": "test.c", "pattern": false, "language": "C", "line": 1, "kind": "file", "roles": "def", "extras": "inputFile", "end": 10}
- {"_type": "tag", "name": "test.h", "path": "test.h", "pattern": false, "language": "C++", "line": 1, "kind": "file", "roles": "def", "extras": "inputFile", "end": 8}
- {"_type": "tag", "name": "var", "path": "test.c", "pattern": "/^int var = 5;$/", "language": "C", "line": 1, "typeref": "typename:int", "kind": "variable", "roles": "def"}
- {"_type": "tag", "name": "var", "path": "test.h", "pattern": "/^extern int var;$/", "language": "C++", "line": 4, "typeref": "typename:int", "kind": "externvar", "roles": "def"}
我们可以看出,ctags生成不了标识符的被引用信息,比如某个符号在哪些地方都被用到了。它只能生成某个头文件在哪个源文件哪个位置引用到了。