In my old project there used to be many #if 0 .. #endif which does not fall in to the comment-face of the c-mode. This always confuses me. It would be good if that block is colored like a comment. So that i can just ignore that place.
I wrote the following elisp code which adds the #if 0 section to the comment section keywords of the c-mode.
(font-lock-add-keywords
'c-mode
'(("\s-*#\s-*if\s-*0\s-*n\(.*n\)*?\s-*#\s-*endif\s-*" 0 font-lock-comment-face append)))
I have left \s-* in many places as it is because even using back reference does not improve any readability.
or u can use gvim and get all these out of the box
Comment by Sankar — January 25, 2009 @ 8:52 am
Nice one !
Comment by Johnny — January 26, 2009 @ 5:26 am
Sankar: Oh really? vim supports this? what happens if the macro has to be processed first.
For example I have,
#define FALSE 0
and
#if FALSE
..
#endif
what will happen, would vim interpret all of this?
And to answer your question, I am not interested to operate my fingers just because my slippers are slightly not fit.
or even,
Just to get the cool air to my room, i would fix a AC, i wont remove my ceiling.
Comment by skalyanasundaram — January 27, 2009 @ 12:37 pm