Aaron Shen
Aaron Shen

Reputation: 8374

How does vim color scheme work for different file types?

I'm new to vim. I want to customize my vim look nice. I find some very nice looking color schemes by google. But I'm wondering how these color scheme work when I open different type of files. I work mainly with javascript. So if I pick SOLARIZED color scheme for example, when I open html or js files, will the color scheme highlight javascript or html syntax differently?

if yes, does that mean a color scheme always contains a complete set of syntax highlighting solution for all kinds of file types?

Upvotes: 0

Views: 883

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172530

Most filetypes (like python) in Vim come with a syntax that defines highlight groups (see them via :highlight). These particular groups (e.g. pythonFunction) are then linked to a set of default groups (:help highlight-groups, e.g. Identifier). A colorscheme then provides combinations of foreground / background color and/or formatting like bold and italic (separately for terminals, color terminals, and/or GVIM) for the default groups.

highlight group → default group → color + style
pythonFunctionIdentifierterm=underline ctermfg=3 guifg=DarkCyan

So, for a set of beautifully matching colors that please your personal taste, you choose a colorscheme. In order to tweak some particular associations, you can change the linking of highlight group to default group, e.g.:

:hi link pythonFunction Special

Upvotes: 2

Related Questions