[英]Vim syntax error highlight
我是vim新手,並且一直在使用某人的vim配置(我已經將他的.vim
目錄克隆到了我的主目錄中)。
看來他的配置存在有關語法檢查的錯誤。 如你看到的:
括號不應突出顯示,因為那里沒有錯誤。
所以我的問題是,我應該檢查vim
配置的哪一部分。
謝謝
更新:0
我想我找到了導致此錯誤的行。
我在~/.vim/syntax/c/extra.vim
有一個extra.vim文件,該文件如下所示:
"========================================================
" Highlight All Function
"========================================================
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
"========================================================
" Highlight All Math Operator
"========================================================
" C math operators
syn match cMathOperator display "[-+\*/%=]"
"" C pointer operators
syn match cPointerOperator display "->\|\."
"" C logical operators - boolean results
syn match cLogicalOperator display "[!<>]=\="
syn match cLogicalOperator display "=="
"" C bit operators
syn match cBinaryOperator display "\(&\||\|\^\|<<\|>>\)=\="
syn match cBinaryOperator display "\~"
syn match cBinaryOperatorError display "\~="
"" More C logical operators - highlight in preference to binary
syn match cLogicalOperator display "&&\|||"
syn match cLogicalOperatorError display "\(&&\|||\)="
" Math Operator
hi def link cMathOperator cOperator
hi def link cPointerOperator cOperator
hi def link cLogicalOperator cOperator
hi def link cBinaryOperator cOperator
hi def link cBinaryOperatorError cOperator
hi def link cLogicalOperator cOperator
hi def link cLogicalOperatorError cOperator
hi def link cFunction Function
hi def link cOperator Operator
" hi Operator guifg=LightGoldenrod
當我注釋掉下面的行時:
syn match cMathOperator display "[-+\*/%=]"
問題不見了。
那么我該如何解決這個問題,為什么呢?
Vim可能尚未檢查整個文件。 這是一種優化,有時會失敗。
通常,向后和向前滾動幾個屏幕可以解決該問題。
您還可以對整個文件進行分析:
:syn sync fromstart
有關更多信息,請檢查Vim常見問題解答24.8:Vim語法突出顯示已損壞。 當我編輯文件時,文件的某些部分沒有語法突出顯示或語法突出顯示不正確。
好的,此錯誤已通過以下方式糾正:
-"syn match cMathOperator display "[-+\*/%=]"
+syn match cMathOperator display "[-+/*/%=]"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.