我正在为自定义语言撰写.tags文件...与大多数语言一样,它允许在一行中作出多个变量声明,即:
int a, b, c;
我有一个基本的regex 承认:
--regex-mylang=/^[ ]*int[ ]*([a-zA-Z_0-9]+)/1/v,variable/
我如何修改此选项使其与 b 和 c 匹配? 我无法在标签文档中找到任何在单行中处理多个匹配的文件 。
我正在为自定义语言撰写.tags文件...与大多数语言一样,它允许在一行中作出多个变量声明,即:
int a, b, c;
我有一个基本的regex 承认:
--regex-mylang=/^[ ]*int[ ]*([a-zA-Z_0-9]+)/1/v,variable/
我如何修改此选项使其与 b 和 c 匹配? 我无法在标签文档中找到任何在单行中处理多个匹配的文件 。
在经过几个小时之后,我确信它无法完成。不管怎样,正则表达式将只扩展为每行一个标签。即使您把 12 3...作为扩展,它只会造成一个由多个匹配组成的标签,而不是每个匹配一个标签。
它正确地诠释了 C 示例, 因为在标签源代码中, 它使用实际的代码解码解析器, 而不是正则表达式 。
< 强超晚 < / 强 > 通用标签可以捕捉它们 。
[jet@localhost]/tmp% cat input.x
int a, b, c;
[jet@localhost]/tmp% cat x.ctags
--langdef=X
--map-X=.x
--kinddef-X=v,var,variables
--_tabledef-X=main
--_tabledef-X=vardef
--_mtable-regex-X=main/int[ ]+//{tenter=vardef}
--_mtable-regex-X=main/.//
--_mtable-regex-X=vardef/([a-zA-Z0-9]+)/1/v/
--_mtable-regex-X=vardef/;//{tleave}
--_mtable-regex-X=vardef/.//
[jet@localhost]/tmp% u-ctags --options=x.ctags -o - ./input.x
a ./input.x /^int a, b, c;$/;" v
b ./input.x /^int a, b, c;$/;" v
c ./input.x /^int a, b, c;$/;" v
您正在试图用正则进行分解, 通常不可能。 分析要求相等于在堆叠中存储信息, 但正则表达式只能包含一定数量的不同状态 。
it can be partialy done with the Universal Ctags and with the help of {_multiline=N}
and {scope}
flag. The N
is group number which position is saved in generated tags
file.
For more information look here: docs/optlib.rst
<坚固>configation: 坚固 > mylang.ctags
--langmap=mylang:.txt
--regex-mylang=/^[[:blank:]]*(int)[[:blank:]]/1/{placeholder}{scope=set}{_multiline=1}
--regex-mylang=/(;)/1/{placeholder}{scope=clear}
--regex-mylang=/[[:blank:]]*([[:alnum:]]+)[[:blank:]]*,?/1/v,variable/{_multiline=1}{scope=ref}
<强度> 测试文件: 强度> test. txt
void main() {
int a, b, c, d;
}
生成标签,使用: ctags --options=mylang.ctags 测试.txt
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
!_TAG_PROGRAM_VERSION 0.0.0 /cb4476eb/
a test.txt /^ int a, b, c, d;$/;" v
b test.txt /^ int a, b, c, d;$/;" v
c test.txt /^ int a, b, c, d;$/;" v
d test.txt /^ int a, b, c, d;$/;" v
int test.txt /^ int a, b, c, d;$/;" v
main test.txt /^void main() {$/;" v
void test.txt /^void main() {$/;" v
I work in a multi-language environment and use Vim + ctags for navigating the code. However we also use CORBA and exuberant ctags does not parse IDL files. Does anyone know of a ctags compatible ...
I m trying to map my own shortcuts in vi. I want to be able to open a splitted window containing the declaration of the function I m calling the shortcut on. something like this in my vimrc: nmap <...
I am using "ExuberantCtags" also known as "ctags -e", also known as just "etags" and I am trying to understand the TAGS file format which is generated by the etags command, in particular I want to ...
I m a big fan of ctags, but sometimes it is hard to use it. In case when I have a few declaration of the functions with the same name - "ctrl + ]" throws you to the first occurrence - which is not ...
I have in my .vimrc: let g:PROJECT1="/a/b/c" let g:PROJECT2="/d/e/f" I then do a bunch of operations on the above strings: let str=":!/usr/bin/ctags ".g:FLAGS_CPP." -f ".g:TAG_FILE." ".g:PROJECT1 ...
I want to use the mac in single user mode. I want to use ctags and cscope in that mode. Could anyone help me with the setups required for this. Thank you. All i know is how to go to the single user ...
I ve recently abandoned mouse-driven, platform-specific GUI editors and committed entirely to vim. The experience so far has been fantastic, but I m stuck when it comes to Javascript. The ever-...
I m building a an external module ( device driver ), i.e. it s not in the Linux kernel source tree, but in a separate unrelated source tree. I want to use ctags to browse variable / function ...