vim 7.3 syntax highlight for c functions

745 views
Skip to first unread message

sinbad

unread,
Nov 12, 2011, 3:27:49 AM11/12/11
to vim_use
hi,

i am trying to syntax highlight the c function calls. i asked google,
someone suggested to add
the following in c.vim.

" Highlight Class and Function names
syn match cCustomParen "(" contains=cParen,cCppParen
syn match cCustomFunc "\w\+\s*(" contains=cCustomParen
syn match cCustomScope "::"
syn match cCustomClass "\w\+\s*::" contains=cCustomScope

hi def link cCustomFunc Function
hi def link cCustomClass Function

but, i have three c.vim's in my environment.

syntax/c.vim
indent/c.vim
ftplugin/c.vim

i tried adding the above in all three and in each one, but it didn't
work, instead
it highlighted the ")" or "}" in RED. where should i put those lines
for it to work
properly.

i also want to highlight the user defined typedef's with a different
color.

for example "some_struct_t", i want to highlight the words ending with
"_t"
with a different color too.

how can i achieve this. btw, why do we have three c.vim's ?

thanks
sinbad

sinbad

unread,
Nov 12, 2011, 10:56:59 PM11/12/11
to vim_use
hi can anyone shed some light on this.

thanks
sinbad

Leiking

unread,
Nov 12, 2011, 11:45:45 PM11/12/11
to vim...@googlegroups.com
try std_c.vim

2011/11/13 sinbad <sinbad...@gmail.com>:

> --
> 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
>

Ivan S. Freitas

unread,
Nov 13, 2011, 1:36:44 AM11/13/11
to vim...@googlegroups.com
On Sun, Nov 13, 2011 at 2:45 AM, Leiking <jinlei...@gmail.com> wrote:
> try std_c.vim

Also look at
http://www.vim.org/scripts/script.php?script_id=3064

To highlight custom function/types, you need to define or link some
highlighting groups. I never saw anything about *_t types/structures,
but it may not be too dificult to extend for it.

--
Ivan Sichmann Freitas
GNU/Linux user #509059

sinbad

unread,
Nov 15, 2011, 12:02:27 AM11/15/11
to vim_use
On Nov 13, 9:45 am, Leiking <jinleileik...@gmail.com> wrote:
> try std_c.vim
>

hi, i tried std_c.vim script, it is working great. except that for
some "c" files
it is throwing the error.

E169: Command too recursive
line 940:
E169: Command too recursive
Press ENTER or type command to continue

this is the culprit line. "exec "syn sync ccomment cComment
minlines=".b:c_minlines"

" Highlight re-syncing distance.
if exists("c_minlines")
let b:c_minlines = c_minlines
else
let b:c_minlines = 15
endif
exec "syn sync ccomment cComment minlines=".b:c_minlines

i don't know much about the "syn sync", is it known issue, have you
been facing the same problem
and any pointers to how to fix it, will be helpful.

thanks
sinabd
Reply all
Reply to author
Forward
0 new messages