[email protected] wrote:
Is it possible to have Vim set the background colour of a multi-line
block
of code surrounded by preprocessor directives? For example (C code):
int func1() {
int i;
for (i=0;i<MAX;i++) {
func2(array[i]);
#if DEBUG
printf("Called func2 with %d\n",array[i]);
debugfunc(i);
#endif
}
printf("func1 all done\n");
}
I'd like the 4 lines between #if and #endif inclusive to have a different
background colour. I don't mind if those lines keep or lose their
regular syntax
colouring, it's more important to me just to have them stand out as a
visually
distinct block.
If there are any examples of syntax files that do this that I could
copy from
that would be ideal - realistically I won't have time to learn the
nuts and bolts
from scratch.
Yes -- but its not easy. Here are the steps:
1. Copy your vim72/syntax/c.vim file to your personal ~/.vim/syntax
directory
2. Modify your colorscheme: duplicate (nearly) all names, prefix
duplicates with something like "PreProc_"
3. Further modify the duplicates to have the desired background color
specified
4. Modify the ~/.vim/syntax/c.vim:
a) Duplicate c.vim, with duplicates having PreProc_ prefixes and use
the "contained" keyword.
b) Have these duplicates call upon PreProc_ colorscheme labels
c) Set up the cPreProc syntax highlighting region to include the
formerly top-level PreProc_ variant matches, regions, and keywords.
Essentially, the idea is to duplicate normal c-syntax + your colorscheme
highlighting while inside PreProc regions, except to use a modified
colorscheme which uses PreProc_ variants for that background you want.
Good luck!
Chip Campbell
--
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