Reputation: 489
I'm vim newbie, and I been using someone's vim configuration(I've cloned his .vim
directory to my home directory).
It seems that his configuration has a bug about syntax checking. As you can see:
The bracket should not be highlighted, cause there is not error there.
So my question is, which part of the vim
configuration should I check for this issue.
Thanks
UPDATE: 0
I think I found the line that cause this bug.
I have a extra.vim file in ~/.vim/syntax/c/extra.vim
the file is looks like:
"========================================================
" 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
When I comment out the line below:
syn match cMathOperator display "[-+\*/%=]"
The issue is gone.
So how can I fix this, and why ?
Upvotes: 1
Views: 1738
Reputation: 489
OK, This Bug is corrected with:
-"syn match cMathOperator display "[-+\*/%=]"
+syn match cMathOperator display "[-+/*/%=]"
Upvotes: 1
Reputation: 9273
Vim probably has not checked the entire file. It is a kind of optimization which sometimes fails.
Usually scrolling the file backwards and forwards a couple of screens solves the problem.
You can also force a analysis on the entire file:
:syn sync fromstart
For more information, check Vim FAQ 24.8: Vim syntax highlighting is broken. When I am editing a file, some parts of the file is not syntax highlighted or syntax highlighted incorrectly.
Upvotes: 1