On 20/01/11 12:10 AM, H Xu wrote:
Hello,

The following C source code is not highlighted properly.
Lines between #if 0 and #endif is not highlighted as comments.

if(
#if 0
cond0 &&
#endif
cond1
)


but if I remove the "if(" they are highlighted as comments.

Hmm. I can't quickly think of any reason not to allow this.

The diff below contains the fix.

To make the change manually, start up vim and

:e $VIMRUNTIME/syntax/c.vim
/syn cluster\tcParenGroup
:s/cCppOut,//
:!mkdir -p ~/.vim/syntax
:sav ~/.vim/syntax/c.vim
:q

The :!mkdir and :sav lines will need to be slightly different if you are on Windows. For starters, .vim will be vimfiles. Hopefully you can figure it out.

Anyway, this will put a revised c.vim in your ~/.vim/syntax directory, which will override the one distributed with Vim. So it won't benefit from updates to the Vim C highlighting that come through, but also won't have the bugfix undone for the same reason. If/when the bugfix is incorporated into the c.vim distributed with Vim, you can remove the file from ~/.vim/syntax to use the Vim one again.

Ben.



--- /usr/local/share/vim/vim73/syntax/c.vim     2011-01-18 22:20:25.000000000 
+1100
+++ c.vim       2011-01-20 09:00:50.000000000 +1100
@@ -80,7 +80,7 @@
 "catch errors caused by wrong parenthesis and brackets
 " also accept <% for {, %> for }, <: for [ and :> for ] (C99)
 " But avoid matching <::.
-syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom +syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom
 if exists("c_no_curly_error")
syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell
   " cCppParen: same as cParen but ends at end-of-line; used in cDefine



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to