C.VIM Syntax file update

68 views
Skip to first unread message

Mark Manning

unread,
Jul 13, 2025, 2:30:01 AMJul 13
to vim_dev
Using Vim 9.1

Hi everyone! I got a C source file and started to edit it and did not see my colors come up like normal. So for the last five hours I have been working on making changes to the C.VIM syntax file. I was wondering if it can be included into the next release. I uploaded it to my account on the VIM website (Bram's website). But I can upload it here if you want.

Things I have done to the file:

1. I went to the IBM webpage on the Standard C functions and copy/pasted all of them into the C.VIM file. Edited the list to just get the function names and built a "syn keyword" list of the functions.
2. I took the generic function code I had put into the iwbasic.vim syntax file and put it at the end of the list of functions so now all functions are captured. (I might need to try some weird function names to make sure I got everything.)
3. Added in the:

hi def link cFunction Function

so the functions will now show up as functions.

4. Put a blurb in about what I did. I put this at the top of the list of functions.

Let me know if you want me to upload it here.

Mark


Christian Brabandt

unread,
Jul 13, 2025, 3:23:17 AMJul 13
to vim...@googlegroups.com
Thanks. Can you create a PR against the Vim repo so we can see what
exactly you are changing? This also runs the test suite, so we will see
any failures early.


Thanks,
Christian
--
A woman's best protection is a little money of her own.
-- Clare Booth Luce, quoted in "The Wit of Women"

Maxim Kim

unread,
Jul 13, 2025, 4:01:59 AMJul 13
to vim_dev
I actually prefer function names to stay normal color, not sure about others.

Having said that I am able to override it for my personal config and in colorschemes I am authoring :)

Mark Manning

unread,
Jul 13, 2025, 4:46:43 PMJul 13
to vim_dev
@Christian Brabandt - I'm sorry - although I have been a part of VIM for many years - I hardly ever get on any of the groups. So my question to you is "What is a PR?" and "How do I do it?"

If there is a web page that explains all of that - please post or send it to me.

Thanks!

Mark

shane.qian

unread,
Jul 14, 2025, 2:55:36 AMJul 14
to vim...@googlegroups.com
> "What is a PR?" and "How do I do it?"

He means 'pull request' in 'Github',
or actually you should be Ok to go with 'git patch' workflow as well;
just send your code patch mail to him. FYI. check ':h develop.txt'

--
shane.xb.qian

Doug Kearns

unread,
Jul 14, 2025, 7:57:08 AMJul 14
to vim...@googlegroups.com
Mark,

Re: https://www.vim.org/scripts/script.php?script_id=6159
We already have general function call highlighting,
https://github.com/vim/vim/blob/master/runtime/syntax/c.vim#L551-L557,
but it hasn't made a release yet.

I had a quick look at your additions and it seems that the library
functions should be defined with :syn-contained and contained in the
general function call syntax group. I'm not sure this should be
enabled by default and it could, optionally, be configured per
library.

My assumption is that this was not an oversight but a preference of
Bram's given the nature of C.

Thanks,
Doug

Mark Manning

unread,
Jul 14, 2025, 5:09:56 PMJul 14
to vim_dev
@Doug Kearns,

Ok. How about if I made it something like

cStandardCLibraryFunctions

as the name and then the list could then be included into a
later cFunction command? Would that be a good idea?  Also,
I think I'm going to have to try the command that is in the
"still to be released" c.vim that you posted about. I want
to test it out to see if it is better than what I put into
my c.vim file. If it is - then I'll take mine back out of
what I have.

Mark Manning

unread,
Jul 14, 2025, 5:16:30 PMJul 14
to vim_dev
Sorry - I decided that name was way too long and shortened it to

     cStdCLibFunctions

Mark Manning

unread,
Jul 15, 2025, 3:24:50 PMJul 15
to vim_dev
Ok. I went online, read the instructions on doing a pull
request, and it said I should download the repository and
work from there. I did that so I had it on my system. I
put in the changes and said to push those back to the
repository. However, GitHub responded that I do not have
privileges to push to the master repsoitory. So should I
just fork the repository at markem/vim? Or do you want me
to do something else? I used to use subversion at NASA
but that was the early 2000's. I use GitHub for my own
projects but I really-really don't want to muck up the
VIM repository. So if you can let me know what I should
do I'd appreciate it.

By changing the name to cStdCLibFunctions - this can now be
used in a contain=cStdCLibFunctions clause or just used on
the "hi def link" command like other names are also used.

I'd also like to include a cSymbols command. Like so:

syn match cSymbols "[\+\-\=\|\*\/\>\<\%\()[\]\!\^\{\}]"

First, I have not put this into the repository. This
is just a "would you like me to put this into the same
file?" question. I, personally, like colorful layouts. It
is easier on my eyes but some people would probably not
like it.  So give me a yes or no on this if you will and
I'll put it in or leave it out. :-)
Message has been deleted
Message has been deleted

Mark Manning

unread,
Jul 15, 2025, 6:16:06 PMJul 15
to vim_dev
Ok, let me try this. (I finally got 'git diff' to work.)

@@ -459,6 +459,58 @@ else
   exec "syn sync ccomment cComment minlines=" . b:c_minlines
 endif
 
+"
+" Standard C Library Functions Table, By Name
+" Put in by Mark Manning on July 12th, 2025.
+"
+syn keyword cStdCLibFunctions abort abs acos asctime asctime_r asin assert atan
+syn keyword cStdCLibFunctions atexit atof atoi atol bsearch btowc calloc catclose
+syn keyword cStdCLibFunctions catgets catopen ceil clearerr clock cos cosh ctime
+syn keyword cStdCLibFunctions ctime64 ctime_r ctime64_r difftime difftime64 div
+syn keyword cStdCLibFunctions erf erfc exit exp fabs fclose fdopen feof ferror
+syn keyword cStdCLibFunctions fflush fgetc fgetpos fgets fgetwc fgetws fileno
+syn keyword cStdCLibFunctions floor fmod fopen fprintf fputc fputs fputwc fputws
+syn keyword cStdCLibFunctions fread free freopen frexp fscanf fseek fsetpos
+syn keyword cStdCLibFunctions ftell fwide fwprintf fwrite fwscanf gamma getc
+syn keyword cStdCLibFunctions getchar getenv gets getwc getwchar gmtime gmtime64
+syn keyword cStdCLibFunctions gmtime_r gmtime64_r hypot isalnum isalpha isascii
+syn keyword cStdCLibFunctions isblank iscntrl isdigit isgraph islower isprint
+syn keyword cStdCLibFunctions ispunct isspace isupper iswalnum iswalpha iswblank
+syn keyword cStdCLibFunctions iswcntrl iswctype iswdigit iswgraph iswlower iswprint
+syn keyword cStdCLibFunctions iswpunct iswspace iswupper iswxdigit isxdigit
+syn keyword cStdCLibFunctions j0 j1 jn labs ldexp ldiv localeconv localtime localtime64
+syn keyword cStdCLibFunctions localtime_r localtime64_r log log10 longjmp malloc
+syn keyword cStdCLibFunctions mblen mbrlen mbrtowc mbsinit mbsrtowcs mbstowcs mbtowc
+syn keyword cStdCLibFunctions memchr memcmp memcpy memmove memset mktime mktime64
+syn keyword cStdCLibFunctions modf nextafter nextafterl nexttoward nexttowardl
+syn keyword cStdCLibFunctions nl_langinfo perror pow printf putc putchar putenv puts
+syn keyword cStdCLibFunctions putwc putwchar qsort quantexpd32 quantexpd64 quantexpd128
+syn keyword cStdCLibFunctions quantized32 quantized64 quantized128 samequantumd32
+syn keyword cStdCLibFunctions samequantumd64 samequantumd128 raise rand rand_r
+syn keyword cStdCLibFunctions realloc regcomp regerror regexec regfree remove
+syn keyword cStdCLibFunctions rename rewind scanf setbuf setjmp setlocale setvbuf
+syn keyword cStdCLibFunctions signal sin sinh snprintf sprintf sqrt srand sscanf
+syn keyword cStdCLibFunctions strcasecmp strcat strchr strcmp strcoll strcpy strcspn
+syn keyword cStdCLibFunctions strerror strfmon4 strftime strlen strncasecmp strncat
+syn keyword cStdCLibFunctions strncmp strncpy strpbrk strptime4 strrchr strspn strstr
+syn keyword cStdCLibFunctions strtod strtod32 strtod64 strtod128 strtof strtok strtok_r
+syn keyword cStdCLibFunctions strtol strtold strtoul strxfrm swprintf swscanf system
+syn keyword cStdCLibFunctions tan tanh time time64 tmpfile tmpnam toascii tolower toupper
+syn keyword cStdCLibFunctions towctrans towlower towupper ungetc ungetwc va_arg va_copy
+syn keyword cStdCLibFunctions va_end va_start vfprintf vfscanf vfwprintf vfwscanf
+syn keyword cStdCLibFunctions vprintf vscanf vsprintf vsnprintf vsscanf vswprintf
+syn keyword cStdCLibFunctions vswscanf vwprintf vwscanf wcrtomb wcscat wcschr wcscmp
+syn keyword cStdCLibFunctions wcscoll wcscpy wcscspn wcsftime wcslen wcslocaleconv
+syn keyword cStdCLibFunctions wcsncat wcsncmp wcsncpy wcspbrk wcsptime wcsrchr
+syn keyword cStdCLibFunctions wcsrtombs wcsspn wcsstr wcstod wcstod32 wcstod64 wcstod128
+syn keyword cStdCLibFunctions wcstof wcstok wcstol wcstold wcstombs wcstoul wcsxfrm4
+syn keyword cStdCLibFunctions wctob wctomb wctrans wctype wcwidth wmemchr wmemcmp
+syn keyword cStdCLibFunctions wmemcpy wmemmove wmemset wprintf wscanf y0 y1 yn
+
+
 " Define the default highlighting.
 " Only used when an item doesn't have highlighting yet
 hi def link cFormat cSpecial
@@ -501,6 +553,8 @@ hi def link cPreConditMatch cPreCondit
 hi def link cPreCondit PreCondit
 hi def link cType Type

 hi def link cFunction Function
+hi def link cStdCLibFunctions StdCLibFunctions
+hi def link cSymbols Symbols
 hi def link cConstant Constant
 hi def link cCommentString cString
 hi def link cComment2String cString
@@ -523,5 +577,3 @@ let &cpo = s:cpo_save
 unlet s:cpo_save
 " vim: ts=8
 
-
-

Mark Manning

unread,
Jul 15, 2025, 6:20:30 PMJul 15
to vim...@googlegroups.com
Ok, I just uploaded the DIFF of the original c.vim file and my c.vim
file. Is this what you think he needs? (Only took me six tries to get
it uploaded. Ugh.)

Mark :-)
> --
> --
> You received this message from the "vim_dev" 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 because you are subscribed to a topic in the Google Groups "vim_dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/sfGfpAsyV8Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/vim_dev/CAJ1uvoD22FtW8zysCmD38nLi%3DYQKBS%2B72ktQGpzEuREt03-LSw%40mail.gmail.com.


--
Mark Manning <mark.euge...@gmail.com>

Christian Brabandt

unread,
Jul 16, 2025, 1:52:00 PMJul 16
to vim...@googlegroups.com, Doug Kearns

On Di, 15 Jul 2025, Mark Manning wrote:

> Ok, let me try this. (I finally got 'git diff' to work.)

Thanks. Now I got 3 slightly varying patches :) Which one would you like
to applied? If I see this correctly, those functions are not
highlighted by default, so that would be the right thing to do. Just
document how this can be achieved in :h ft-c-syntax

@Doug are you fine with this?

Thanks,
Chris

Doug Kearns

unread,
Jul 16, 2025, 2:22:52 PMJul 16
to vim...@googlegroups.com
No, but I'm not sure I'm seeing the same final patch.

I'll make a pull request with these changes tomorrow and we can
discuss it there.

Thanks,
Doug

Mark Manning

unread,
Jul 16, 2025, 4:37:25 PMJul 16
to vim...@googlegroups.com
Thank you. I mucked up trying to upload the diff a couple of times and thought I had deleted them. But at least this is now down. :-) Thank you again both Doug and Christian.


--
--
You received this message from the "vim_dev" 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 because you are subscribed to a topic in the Google Groups "vim_dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/sfGfpAsyV8Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages