我试图通过GVim在C ++中突出我自己的类名和函数名。 我从stackoverflow中读取并跟踪link。另请查看结果link
我在cpp.vim中复制了以下内容,位于语法目录下。
" Highlight Class and Function names
syn match cCustomParen "(" contains=cParen,cCppParen
syn match cCustomFunc "\w\+\s*(" contains=cCustomParen
syn match cCustomScope "::"
syn match cCustomClass "\w\+\s*::" contains=cCustomScope
hi def link cCustomFunc Function
hi def link cCustomClass Function
它有效,但用红色突出显示我的括号。如何禁用括号的突出显示? 我删除了.vimrc文件并再次打开我的cpp文件,它仍然相同。所以我认为这是上面的代码问题。
--------------------已解决[解决方案] --------------------
syn match customFunc "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match customFunc "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
hi def customFunc gui=NONE guifg=#E54023
syn match cCustomScope "::"
syn match cCustomClass "\w\+\s*::" contains=cCustomScope
hi def link cCustomClass Function
--------------------------- EOF ------------------- -----------
答案 0 :(得分:3)
您应该编辑.vimrc
文件。只需将此行添加到文件中:
let g:loaded_matchparen= 1
答案 1 :(得分:0)
您没有在更改中引入匹配的括号。它的vim默认行为。 所以,只需添加
let g:loaded_matchparen= 1
到您的.vimrc文件。