I've installed macvim with Homebrew; OS X version 10.11.6; macvim version:
macvim: stable 8.0-119 (bottled), HEAD
But it doesn't color printf
, scanf
by default while editing "my file.c".
I've searched that how to add them by creating ~/.vim/after/c.vim
.
(another way come through my mind is to edit the default c.vim file directly, but I don't know where they are).
In my ~/.vim/after/c.vim
I wrote:
syn keyword printf scarf
and it didn't work...(If I know where the default c.vim file is, I could refer to it and maybe my problem could be solved.)
btw, I download c.vim from vim.org, but I found the last-edited date was in 2010, if I want the C11 standard version where could I get one, if it matters(?).
Is it a good practice that not to change the default syntax-highlight-file like c.vim, and add my own by ~/.vim/after/
or ~/.vim/syntax/
?
Create
~/.vim/after/syntax/c.vim
file (as recommended in the official documentation) with the following content:As far as I can see, the default syntax rules do not highlight the functions, even from the standard library. So you need to add them yourself.
The
syn
command addsprintf
andscanf
to thecFunctions
highlighting group.The
hi
command linkscFunctions
group to theFunction
highlight group, which is usually defined by the colorscheme. If theFunction
group is not defined, you can define it yourself, e.g.Yes, of course. The syntax files are usually distributed as packages. For example, on my Gentoo Linux
/usr/share/vim/vim80/syntax/c.vim
is shipped withapp-editors/vim-core
package. The local modifications to the syntax files will be overwritten the next time the package is upgraded.