我正在自定义标准的"c.vim"语法文件,以便调整我的C代码的可视化.我想区分"被调用函数"的颜色与"声明函数"之一.
例:
int declared_function()
{
int m;
m = called_function();
return (m)
}
Run Code Online (Sandbox Code Playgroud)
我深入阅读了VIM文档以及数百万个论坛和谷歌搜索结果,但我尝试过的所有解决方案都无效.
要恢复,我这样做了:
我以递归方式定义了一个区域,以便考虑大括号内的所有代码:
syn region Body start="{" end="}" contains=Body
Run Code Online (Sandbox Code Playgroud)
然后我通过VIM模式定义了一般函数语法:
syn match cFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cType,cDelimiter,cDefine
Run Code Online (Sandbox Code Playgroud)
我这样做是因为我认为我可以在.vimrc文件中的"if else"条件中将两者合并......但是经过一整天的测试失败后,我需要有人的帮助,他可以告诉我是否可能以及如何去做吧.
谢谢大家.
我是正则表达式的菜鸟。
我必须匹配字面上不同的字符串组合。如示例中所示:
"feed the cat."
"feed the dog."
"feed the bear."
Run Code Online (Sandbox Code Playgroud)
但不是
"feed the eagle."
"feed the monkey."
"feed the donkey."
Run Code Online (Sandbox Code Playgroud)
我尝试了类似的方法,/^feed the [cat|dog|bear].$/但是没有用。网上提供的备忘单解释了很多复杂的事情,但并不能说明我如何从字面上匹配多个字符串...
感谢您的帮助。