Quantcast

vim 7.3 syntax highlight for c functions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

vim 7.3 syntax highlight for c functions

sinbadd
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

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: vim 7.3 syntax highlight for c functions

sinbadd
On Nov 12, 1:27 pm, sinbad <[hidden email]> wrote:

> 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

hi can anyone shed some light on this.

thanks
sinbad

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: vim 7.3 syntax highlight for c functions

Leiking
try std_c.vim

2011/11/13 sinbad <[hidden email]>:

> On Nov 12, 1:27 pm, sinbad <[hidden email]> wrote:
>> 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
>
> hi can anyone shed some light on this.
>
> thanks
> sinbad
>
> --
> 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
>

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: vim 7.3 syntax highlight for c functions

Ivan Sichmann Freitas
On Sun, Nov 13, 2011 at 2:45 AM, Leiking <[hidden email]> 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

--
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: vim 7.3 syntax highlight for c functions

sinbadd
In reply to this post by Leiking
On Nov 13, 9:45 am, Leiking <[hidden email]> 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

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